llvm.org GIT mirror llvm / 17b443d
Second set of ARM/MC/ELF changes. Added ARM specific ELF section types. Added AttributesSection to ARMElfTargetObject First step in unifying .cpu assembly tag with ELF/.o llc now asserts on actual ELF emission on -filetype=obj :-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116257 91177308-0d34-0410-b5e6-96231b3b80d8 Jason W Kim 9 years ago
5 changed file(s) with 84 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
120120 // referenced symbol table contain the escape value SHN_XINDEX
121121 SHT_SYMTAB_SHNDX = 0x12U,
122122
123 LAST_KNOWN_SECTION_TYPE = SHT_SYMTAB_SHNDX
123 // Start of target-specific flags.
124
125 // Exception Index table
126 SHT_ARM_EXIDX = 0x70000001U,
127 // BPABI DLL dynamic linking pre-emption map
128 SHT_ARM_PREEMPTMAP = 0x70000002U,
129 // Object file compatibility attributes
130 SHT_ARM_ATTRIBUTES = 0x70000003U,
131 SHT_ARM_DEBUGOVERLAY = 0x70000004U,
132 SHT_ARM_OVERLAYSECTION = 0x70000005U,
133
134 LAST_KNOWN_SECTION_TYPE = SHT_ARM_OVERLAYSECTION
124135 };
125136
126137 /// Valid section flags.
2020 #include "ARMMachineFunctionInfo.h"
2121 #include "ARMMCInstLower.h"
2222 #include "ARMTargetMachine.h"
23 #include "ARMTargetObjectFile.h"
2324 #include "llvm/Analysis/DebugInfo.h"
2425 #include "llvm/Constants.h"
2526 #include "llvm/Module.h"
2930 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
3031 #include "llvm/CodeGen/MachineFunctionPass.h"
3132 #include "llvm/CodeGen/MachineJumpTableInfo.h"
32 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
3333 #include "llvm/MC/MCAsmInfo.h"
3434 #include "llvm/MC/MCContext.h"
3535 #include "llvm/MC/MCExpr.h"
109109 private:
110110 // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
111111 void emitAttributes();
112 void emitTextAttribute(ARMBuildAttrs::SpecialAttr attr, StringRef v);
112113 void emitAttribute(ARMBuildAttrs::AttrType attr, int v);
114
115 // Helper for ELF .o only
116 void emitARMAttributeSection();
113117
114118 public:
115119 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
494498 // Instead of subclassing the MCELFStreamer, we do the work here.
495499
496500 void ARMAsmPrinter::emitAttributes() {
497 // FIXME: Add in ELF specific section handling here.
498
499 // FIXME: unify this: .cpu and CPUString with enum attributes
501
502 emitARMAttributeSection();
503
500504 std::string CPUString = Subtarget->getCPUString();
501 if (CPUString != "generic")
502 OutStreamer.EmitRawText("\t.cpu " + Twine(CPUString));
505 emitTextAttribute(ARMBuildAttrs::SEL_CPU, CPUString);
503506
504507 // FIXME: Emit FPU type
505508 if (Subtarget->hasVFP2())
528531 // FIXME: Should we signal R9 usage?
529532 }
530533
534 void ARMAsmPrinter::emitARMAttributeSection() {
535 //
536 // [ "vendor-name"
537 // [ *
538 // | * 0 *
539 // | * 0 *
540 // ]+
541 // ]*
542
543 if (OutStreamer.hasRawTextSupport())
544 return;
545
546 const ARMElfTargetObjectFile &TLOFELF =
547 static_cast
548 (getObjFileLowering());
549
550 OutStreamer.SwitchSection(TLOFELF.getAttributesSection());
551 // Fixme: Still more to do here.
552 }
553
531554 void ARMAsmPrinter::emitAttribute(ARMBuildAttrs::AttrType attr, int v) {
532555 if (OutStreamer.hasRawTextSupport()) {
533556 OutStreamer.EmitRawText("\t.eabi_attribute " +
535558
536559 } else {
537560 assert(0 && "ELF .ARM.attributes unimplemented");
561 }
562 }
563
564 void ARMAsmPrinter::emitTextAttribute(ARMBuildAttrs::SpecialAttr attr,
565 StringRef val) {
566 switch (attr) {
567 default: assert(0 && "Unimplemented ARMBuildAttrs::SpecialAttr"); break;
568 case ARMBuildAttrs::SEL_CPU:
569 if (OutStreamer.hasRawTextSupport()) {
570 if (val != "generic") {
571 OutStreamer.EmitRawText("\t.cpu " + val);
572 }
573 } else {
574 // FIXME: ELF
575 }
538576 }
539577 }
540578
1515 #define __TARGET_ARMBUILDATTRS_H__
1616
1717 namespace ARMBuildAttrs {
18 enum SpecialAttr {
19 // This is for the .cpu asm attr. It translates into one or more
20 // AttrType (below) entries in the .ARM.attributes section in the ELF.
21 SEL_CPU
22 };
23
1824 enum AttrType {
25 // Rest correspond to ELF/.ARM.attributes
1926 File = 1,
2027 Section = 2,
2128 Symbol = 3,
5865 Virtualization_use = 68,
5966 MPextension_use = 70
6067 };
68
69 // Magic numbers for .ARM.attributes
70 enum AttrMagic {
71 Format_Version = 0x41
72 };
6173 }
6274
6375 #endif // __TARGET_ARMBUILDATTRS_H__
3535 MCSectionELF::SHF_ALLOC,
3636 SectionKind::getDataRel());
3737 }
38
39 AttributesSection =
40 getContext().getELFSection(".ARM.attributes",
41 MCSectionELF::SHT_ARM_ATTRIBUTES,
42 0,
43 SectionKind::getMetadata());
3844 }
1717 class TargetMachine;
1818
1919 class ARMElfTargetObjectFile : public TargetLoweringObjectFileELF {
20 protected:
21 const MCSection *AttributesSection;
2022 public:
21 ARMElfTargetObjectFile() : TargetLoweringObjectFileELF() {}
23 ARMElfTargetObjectFile() :
24 TargetLoweringObjectFileELF(),
25 AttributesSection(NULL)
26 {}
2227
2328 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
29
30 virtual const MCSection *getAttributesSection() const {
31 return AttributesSection;
32 }
2433 };
2534
2635 } // end namespace llvm