llvm.org GIT mirror llvm / 4186005
Print a=b as an assignment. In assembly the expression a=b is parsed as an assignment, so it should be printed as one. This remove a truly horrible hack for producing a label with "a=.". It would be used by codegen but would never be reached by the asm parser. Sorry I missed this when it was first committed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211639 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
17 changed file(s) with 19 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
115115 /// This is appended to emitted labels. Defaults to ":"
116116 const char *LabelSuffix;
117117
118 /// This is appended to emitted labels. Defaults to ":"
119 const char *DebugLabelSuffix;
118 // Print the EH begin symbol with an assignment. Defaults to false.
119 bool UseAssignmentForEHBegin;
120120
121121 /// This prefix is used for globals like constant pool entries that are
122122 /// completely private to the .s file and should not have names in the .o
414414 const char *getCommentString() const { return CommentString; }
415415 const char *getLabelSuffix() const { return LabelSuffix; }
416416
417 const char *getDebugLabelSuffix() const { return DebugLabelSuffix; }
417 bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
418418 const char *getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }
419419 bool hasLinkerPrivateGlobalPrefix() const {
420420 return LinkerPrivateGlobalPrefix[0] != '\0';
4747 void ChangeSection(const MCSection *Section,
4848 const MCExpr *Subsection) override;
4949 void EmitLabel(MCSymbol *Symbol) override;
50 void EmitDebugLabel(MCSymbol *Symbol) override;
5150 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
5251 void EmitThumbFunc(MCSymbol *Func) override;
5352 void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
8686 /// @{
8787
8888 void EmitLabel(MCSymbol *Symbol) override;
89 void EmitDebugLabel(MCSymbol *Symbol) override;
9089 void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
9190 void EmitValueImpl(const MCExpr *Value, unsigned Size,
9291 const SMLoc &Loc = SMLoc()) override;
391391 // FIXME: These emission are non-const because we mutate the symbol to
392392 // add the section we're emitting it to later.
393393 virtual void EmitLabel(MCSymbol *Symbol);
394
395 virtual void EmitDebugLabel(MCSymbol *Symbol);
396394
397395 virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
398396
3434
3535 void InitSections() override;
3636 void EmitLabel(MCSymbol *Symbol) override;
37 void EmitDebugLabel(MCSymbol *Symbol) override;
3837 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
3938 void EmitThumbFunc(MCSymbol *Func) override;
4039 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
111111 TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI);
112112 Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding);
113113
114 Asm->OutStreamer.EmitDebugLabel
115 (Asm->GetTempSymbol("eh_func_begin",
116 Asm->getFunctionNumber()));
114 MCSymbol *EHBegin =
115 Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
116 if (Asm->MAI->useAssignmentForEHBegin()) {
117 MCContext &Ctx = Asm->OutContext;
118 MCSymbol *CurPos = Ctx.CreateTempSymbol();
119 Asm->OutStreamer.EmitLabel(CurPos);
120 Asm->OutStreamer.EmitAssignment(EHBegin,
121 MCSymbolRefExpr::Create(CurPos, Ctx));
122 } else {
123 Asm->OutStreamer.EmitLabel(EHBegin);
124 }
117125
118126 // Provide LSDA information.
119127 if (!shouldEmitLSDA)
654654 void EmitLabel(MCSymbol *Symbol) override {
655655 Symbol->setSection(*getCurrentSection().first);
656656 markDefined(*Symbol);
657 }
658 void EmitDebugLabel(MCSymbol *Symbol) override {
659 EmitLabel(Symbol);
660657 }
661658 void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override {
662659 // FIXME: should we handle aliases?
3838 SeparatorString = ";";
3939 CommentString = "#";
4040 LabelSuffix = ":";
41 DebugLabelSuffix = ":";
41 UseAssignmentForEHBegin = false;
4242 PrivateGlobalPrefix = "L";
4343 LinkerPrivateGlobalPrefix = "";
4444 InlineAsmStart = "APP";
119119
120120 void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override;
121121 void EmitLabel(MCSymbol *Symbol) override;
122 void EmitDebugLabel(MCSymbol *Symbol) override;
123122
124123 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
125124 void EmitLinkerOptions(ArrayRef Options) override;
330329 IsFirst = false;
331330 OS << **It;
332331 }
333 EmitEOL();
334 }
335
336 void MCAsmStreamer::EmitDebugLabel(MCSymbol *Symbol) {
337 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
338 MCStreamer::EmitDebugLabel(Symbol);
339
340 OS << *Symbol << MAI->getDebugLabelSuffix();
341332 EmitEOL();
342333 }
343334
6262 MCSymbolData &SD = getAssembler().getSymbolData(*Symbol);
6363 if (Section.getFlags() & ELF::SHF_TLS)
6464 MCELF::SetType(SD, ELF::STT_TLS);
65 }
66
67 void MCELFStreamer::EmitDebugLabel(MCSymbol *Symbol) {
68 EmitLabel(Symbol);
6965 }
7066
7167 void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
5959
6060 void ChangeSection(const MCSection *Sect, const MCExpr *Subsect) override;
6161 void EmitLabel(MCSymbol *Symbol) override;
62 void EmitDebugLabel(MCSymbol *Symbol) override;
6362 void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
6463 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
6564 void EmitLinkerOptions(ArrayRef Options) override;
161160 SD.setFlags(SD.getFlags() & ~SF_ReferenceTypeMask);
162161 }
163162
164 void MCMachOStreamer::EmitDebugLabel(MCSymbol *Symbol) {
165 EmitLabel(Symbol);
166 }
167163 void MCMachOStreamer::EmitDataRegion(DataRegionData::KindTy Kind) {
168164 if (!getAssembler().getBackend().hasDataInCodeSupport())
169165 return;
3131 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
3232 assert(getCurrentSection().first &&"Cannot emit before setting section!");
3333 AssignSection(Symbol, getCurrentSection().first);
34 }
35 void EmitDebugLabel(MCSymbol *Symbol) override {
36 EmitLabel(Symbol);
3734 }
3835 void EmitAssemblerFlag(MCAssemblerFlag Flag) override {}
3936 void EmitThumbFunc(MCSymbol *Func) override {}
157157 SD.setOffset(F->getContents().size());
158158 }
159159
160 void MCObjectStreamer::EmitDebugLabel(MCSymbol *Symbol) {
161 EmitLabel(Symbol);
162 }
163
164160 void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value) {
165161 int64_t IntValue;
166162 if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) {
238238 TS->emitLabel(Symbol);
239239 }
240240
241 void MCStreamer::EmitDebugLabel(MCSymbol *Symbol) {
242 assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
243 assert(getCurrentSection().first && "Cannot emit before setting section!");
244 AssignSection(Symbol, getCurrentSection().first);
245 }
246
247241 void MCStreamer::EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding) {
248242 EnsureValidFrame();
249243 MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
8181 MCObjectStreamer::EmitLabel(Symbol);
8282 }
8383
84 void MCWinCOFFStreamer::EmitDebugLabel(MCSymbol *Symbol) {
85 EmitLabel(Symbol);
86 }
87
8884 void MCWinCOFFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
8985 llvm_unreachable("not implemented");
9086 }
3737 ZeroDirective = "\t.space\t";
3838 GPRel32Directive = "\t.gpword\t";
3939 GPRel64Directive = "\t.gpdword\t";
40 DebugLabelSuffix = "=.";
40 UseAssignmentForEHBegin = true;
4141 SupportsDebugInformation = true;
4242 ExceptionsType = ExceptionHandling::DwarfCFI;
4343 HasLEB128 = true;
0 ; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
11
2 ;16: $eh_func_begin0=.
2 ;16: .cfi_personality
3 ;16-NEXT: [[TMP:.*]]:
4 ;16-NEXT: $eh_func_begin0 = ([[TMP]])
35 @.str = private unnamed_addr constant [7 x i8] c"hello\0A\00", align 1
46 @_ZTIi = external constant i8*
57 @.str1 = private unnamed_addr constant [15 x i8] c"exception %i \0A\00", align 1