[llvm] r207381 - Add emitThumbSet to the arm target streamer.
Rafael Espindola
rafael.espindola at gmail.com
Sun Apr 27 13:23:59 PDT 2014
Author: rafael
Date: Sun Apr 27 15:23:58 2014
New Revision: 207381
URL: http://llvm.org/viewvc/llvm-project?rev=207381&view=rev
Log:
Add emitThumbSet to the arm target streamer.
This fixes the asm printer implementation and lets the parser be unaware of
what .thumb_set is.
Modified:
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
llvm/trunk/test/MC/ARM/thumb_set.s
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=207381&r1=207380&r2=207381&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Sun Apr 27 15:23:58 2014
@@ -121,6 +121,8 @@ public:
virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
+ virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
+
void finish() override;
/// Callback used to implement the ldr= pseudo.
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=207381&r1=207380&r2=207381&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Sun Apr 27 15:23:58 2014
@@ -9372,36 +9372,7 @@ bool ARMAsmParser::parseDirectiveThumbSe
Lex();
MCSymbol *Alias = getContext().GetOrCreateSymbol(Name);
- if (const MCSymbolRefExpr *SRE = dyn_cast<MCSymbolRefExpr>(Value)) {
- MCSymbol *Sym = getContext().LookupSymbol(SRE->getSymbol().getName());
- if (!Sym->isDefined()) {
- getStreamer().EmitSymbolAttribute(Sym, MCSA_Global);
- getStreamer().EmitAssignment(Alias, Value);
- return false;
- }
-
- const MCObjectFileInfo::Environment Format =
- getContext().getObjectFileInfo()->getObjectFileType();
- switch (Format) {
- case MCObjectFileInfo::IsCOFF: {
- char Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
- getStreamer().EmitCOFFSymbolType(Type);
- // .set values are always local in COFF
- getStreamer().EmitSymbolAttribute(Alias, MCSA_Local);
- break;
- }
- case MCObjectFileInfo::IsELF:
- getStreamer().EmitSymbolAttribute(Alias, MCSA_ELF_TypeFunction);
- break;
- case MCObjectFileInfo::IsMachO:
- break;
- }
- }
-
- // FIXME: set the function as being a thumb function via the assembler
- getStreamer().EmitThumbFunc(Alias);
- getStreamer().EmitAssignment(Alias, Value);
-
+ getTargetStreamer().emitThumbSet(Alias, Value);
return false;
}
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp?rev=207381&r1=207380&r2=207381&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp Sun Apr 27 15:23:58 2014
@@ -140,6 +140,7 @@ class ARMTargetAsmStreamer : public ARMT
void finishAttributeSection() override;
void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
+ void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
public:
ARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
@@ -261,6 +262,10 @@ ARMTargetAsmStreamer::AnnotateTLSDescrip
OS << "\t.tlsdescseq\t" << S->getSymbol().getName();
}
+void ARMTargetAsmStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
+ OS << "\t.thumb_set\t" << *Symbol << ", " << *Value << '\n';
+}
+
void ARMTargetAsmStreamer::emitInst(uint32_t Inst, char Suffix) {
OS << "\t.inst";
if (Suffix)
@@ -410,6 +415,7 @@ private:
void emitLabel(MCSymbol *Symbol) override;
void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
+ void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
size_t calculateContentSize() const;
@@ -998,6 +1004,23 @@ void
ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
getStreamer().EmitFixup(S, FK_Data_4);
}
+
+void ARMTargetELFStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
+ if (const MCSymbolRefExpr *SRE = dyn_cast<MCSymbolRefExpr>(Value)) {
+ // FIXME: Doing a lookup in here is a hack.
+ MCSymbol *Sym =
+ getStreamer().getContext().LookupSymbol(SRE->getSymbol().getName());
+ if (!Sym->isDefined()) {
+ getStreamer().EmitSymbolAttribute(Sym, MCSA_Global);
+ getStreamer().EmitAssignment(Symbol, Value);
+ return;
+ }
+ }
+
+ getStreamer().EmitThumbFunc(Symbol);
+ getStreamer().EmitAssignment(Symbol, Value);
+}
+
void ARMTargetELFStreamer::emitInst(uint32_t Inst, char Suffix) {
getStreamer().emitInst(Inst, Suffix);
}
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp?rev=207381&r1=207380&r2=207381&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp Sun Apr 27 15:23:58 2014
@@ -246,3 +246,7 @@ void ARMTargetStreamer::AnnotateTLSDescr
const MCSymbolRefExpr *SRE) {
llvm_unreachable("unimplemented");
}
+
+void ARMTargetStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
+ llvm_unreachable("unimplemented");
+}
Modified: llvm/trunk/test/MC/ARM/thumb_set.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/thumb_set.s?rev=207381&r1=207380&r2=207381&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/thumb_set.s (original)
+++ llvm/trunk/test/MC/ARM/thumb_set.s Sun Apr 27 15:23:58 2014
@@ -1,6 +1,9 @@
@ RUN: llvm-mc -triple armv7-eabi -filetype obj -o - %s | llvm-readobj -t \
@ RUN: | FileCheck %s
+@ RUN: llvm-mc -triple armv7-eabi -filetype asm -o - %s \
+@ RUN: | FileCheck --check-prefix=ASM %s
+
.syntax unified
.arm
@@ -11,6 +14,8 @@ arm_func:
.thumb_set alias_arm_func, arm_func
+@ ASM: .thumb_set alias_arm_func, arm_func
+
.thumb
.type thumb_func,%function
More information about the llvm-commits
mailing list