llvm.org GIT mirror llvm / 2dc04b4
Add emitThumbSet to the arm target streamer. This fixes the asm printer implementation and lets the parser be unaware of what .thumb_set is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207381 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
5 changed file(s) with 35 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
119119 virtual void emitInst(uint32_t Inst, char Suffix = '\0');
120120
121121 virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
122
123 virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
122124
123125 void finish() override;
124126
93719371 Lex();
93729372
93739373 MCSymbol *Alias = getContext().GetOrCreateSymbol(Name);
9374 if (const MCSymbolRefExpr *SRE = dyn_cast(Value)) {
9375 MCSymbol *Sym = getContext().LookupSymbol(SRE->getSymbol().getName());
9376 if (!Sym->isDefined()) {
9377 getStreamer().EmitSymbolAttribute(Sym, MCSA_Global);
9378 getStreamer().EmitAssignment(Alias, Value);
9379 return false;
9380 }
9381
9382 const MCObjectFileInfo::Environment Format =
9383 getContext().getObjectFileInfo()->getObjectFileType();
9384 switch (Format) {
9385 case MCObjectFileInfo::IsCOFF: {
9386 char Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
9387 getStreamer().EmitCOFFSymbolType(Type);
9388 // .set values are always local in COFF
9389 getStreamer().EmitSymbolAttribute(Alias, MCSA_Local);
9390 break;
9391 }
9392 case MCObjectFileInfo::IsELF:
9393 getStreamer().EmitSymbolAttribute(Alias, MCSA_ELF_TypeFunction);
9394 break;
9395 case MCObjectFileInfo::IsMachO:
9396 break;
9397 }
9398 }
9399
9400 // FIXME: set the function as being a thumb function via the assembler
9401 getStreamer().EmitThumbFunc(Alias);
9402 getStreamer().EmitAssignment(Alias, Value);
9403
9374 getTargetStreamer().emitThumbSet(Alias, Value);
94049375 return false;
94059376 }
94069377
139139 void finishAttributeSection() override;
140140
141141 void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
142 void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
142143
143144 public:
144145 ARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
258259 void
259260 ARMTargetAsmStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
260261 OS << "\t.tlsdescseq\t" << S->getSymbol().getName();
262 }
263
264 void ARMTargetAsmStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
265 OS << "\t.thumb_set\t" << *Symbol << ", " << *Value << '\n';
261266 }
262267
263268 void ARMTargetAsmStreamer::emitInst(uint32_t Inst, char Suffix) {
409414 void emitLabel(MCSymbol *Symbol) override;
410415
411416 void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
417 void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
412418
413419 size_t calculateContentSize() const;
414420
9971003 ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
9981004 getStreamer().EmitFixup(S, FK_Data_4);
9991005 }
1006
1007 void ARMTargetELFStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
1008 if (const MCSymbolRefExpr *SRE = dyn_cast(Value)) {
1009 // FIXME: Doing a lookup in here is a hack.
1010 MCSymbol *Sym =
1011 getStreamer().getContext().LookupSymbol(SRE->getSymbol().getName());
1012 if (!Sym->isDefined()) {
1013 getStreamer().EmitSymbolAttribute(Sym, MCSA_Global);
1014 getStreamer().EmitAssignment(Symbol, Value);
1015 return;
1016 }
1017 }
1018
1019 getStreamer().EmitThumbFunc(Symbol);
1020 getStreamer().EmitAssignment(Symbol, Value);
1021 }
1022
10001023 void ARMTargetELFStreamer::emitInst(uint32_t Inst, char Suffix) {
10011024 getStreamer().emitInst(Inst, Suffix);
10021025 }
245245 const MCSymbolRefExpr *SRE) {
246246 llvm_unreachable("unimplemented");
247247 }
248
249 void ARMTargetStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
250 llvm_unreachable("unimplemented");
251 }
0 @ RUN: llvm-mc -triple armv7-eabi -filetype obj -o - %s | llvm-readobj -t \
11 @ RUN: | FileCheck %s
2
3 @ RUN: llvm-mc -triple armv7-eabi -filetype asm -o - %s \
4 @ RUN: | FileCheck --check-prefix=ASM %s
25
36 .syntax unified
47
912 nop
1013
1114 .thumb_set alias_arm_func, arm_func
15
16 @ ASM: .thumb_set alias_arm_func, arm_func
1217
1318 .thumb
1419