LLVM API Documentation
00001 //===-- RecordStreamer.cpp - Record asm definde and used symbols ----------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #include "RecordStreamer.h" 00011 #include "llvm/MC/MCSymbol.h" 00012 using namespace llvm; 00013 00014 void RecordStreamer::markDefined(const MCSymbol &Symbol) { 00015 State &S = Symbols[Symbol.getName()]; 00016 switch (S) { 00017 case DefinedGlobal: 00018 case Global: 00019 S = DefinedGlobal; 00020 break; 00021 case NeverSeen: 00022 case Defined: 00023 case Used: 00024 S = Defined; 00025 break; 00026 } 00027 } 00028 00029 void RecordStreamer::markGlobal(const MCSymbol &Symbol) { 00030 State &S = Symbols[Symbol.getName()]; 00031 switch (S) { 00032 case DefinedGlobal: 00033 case Defined: 00034 S = DefinedGlobal; 00035 break; 00036 00037 case NeverSeen: 00038 case Global: 00039 case Used: 00040 S = Global; 00041 break; 00042 } 00043 } 00044 00045 void RecordStreamer::markUsed(const MCSymbol &Symbol) { 00046 State &S = Symbols[Symbol.getName()]; 00047 switch (S) { 00048 case DefinedGlobal: 00049 case Defined: 00050 case Global: 00051 break; 00052 00053 case NeverSeen: 00054 case Used: 00055 S = Used; 00056 break; 00057 } 00058 } 00059 00060 void RecordStreamer::visitUsedSymbol(const MCSymbol &Sym) { markUsed(Sym); } 00061 00062 RecordStreamer::const_iterator RecordStreamer::begin() { 00063 return Symbols.begin(); 00064 } 00065 00066 RecordStreamer::const_iterator RecordStreamer::end() { return Symbols.end(); } 00067 00068 RecordStreamer::RecordStreamer(MCContext &Context) : MCStreamer(Context) {} 00069 00070 void RecordStreamer::EmitInstruction(const MCInst &Inst, 00071 const MCSubtargetInfo &STI) { 00072 MCStreamer::EmitInstruction(Inst, STI); 00073 } 00074 00075 void RecordStreamer::EmitLabel(MCSymbol *Symbol) { 00076 MCStreamer::EmitLabel(Symbol); 00077 markDefined(*Symbol); 00078 } 00079 00080 void RecordStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { 00081 markDefined(*Symbol); 00082 MCStreamer::EmitAssignment(Symbol, Value); 00083 } 00084 00085 bool RecordStreamer::EmitSymbolAttribute(MCSymbol *Symbol, 00086 MCSymbolAttr Attribute) { 00087 if (Attribute == MCSA_Global) 00088 markGlobal(*Symbol); 00089 return true; 00090 } 00091 00092 void RecordStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, 00093 uint64_t Size, unsigned ByteAlignment) { 00094 markDefined(*Symbol); 00095 } 00096 00097 void RecordStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 00098 unsigned ByteAlignment) { 00099 markDefined(*Symbol); 00100 }