summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorAnton Korobeynikov <anton@korobeynikov.info>2019-01-16 14:03:41 +0000
committerAnton Korobeynikov <anton@korobeynikov.info>2019-01-16 14:03:41 +0000
commitcbdb4effae0d641d41e8b71e463ada7831884315 (patch)
tree022393dfa65f29a5cffa68885458ed4ffe88cd58 /llvm/lib/Target
parent383e8271212bfabb824161c9c30e22afa07d44e2 (diff)
downloadbcm5719-llvm-cbdb4effae0d641d41e8b71e463ada7831884315.tar.gz
bcm5719-llvm-cbdb4effae0d641d41e8b71e463ada7831884315.zip
[MSP430] Emit a separate section for every interrupt vector
This is LLVM part of D56663 Linker scripts shipped by TI require to have every interrupt vector in a separate section with a specific name: SECTIONS { __interrupt_vector_XX : { KEEP (*(__interrupt_vector_XX )) } > VECTXX ... } Follow the requirement emit the section for every vector which contain address of interrupt handler: .section __interrupt_vector_XX,"ax",@progbits .word %isr% Patch by Kristina Bessonova! Differential Revision: https://reviews.llvm.org/D56664 llvm-svn: 351345
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp
index f39c21fc8aa..5e9b108c2de 100644
--- a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp
+++ b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp
@@ -17,6 +17,7 @@
#include "MSP430InstrInfo.h"
#include "MSP430MCInstLower.h"
#include "MSP430TargetMachine.h"
+#include "llvm/BinaryFormat/ELF.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
@@ -28,6 +29,7 @@
#include "llvm/IR/Module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/TargetRegistry.h"
@@ -44,6 +46,8 @@ namespace {
StringRef getPassName() const override { return "MSP430 Assembly Printer"; }
+ bool runOnMachineFunction(MachineFunction &MF) override;
+
void printOperand(const MachineInstr *MI, int OpNum,
raw_ostream &O, const char* Modifier = nullptr);
void printSrcMemOperand(const MachineInstr *MI, int OpNum,
@@ -55,6 +59,8 @@ namespace {
unsigned OpNo, unsigned AsmVariant,
const char *ExtraCode, raw_ostream &O) override;
void EmitInstruction(const MachineInstr *MI) override;
+
+ void EmitInterruptVectorSection(MachineFunction &ISR);
};
} // end of anonymous namespace
@@ -153,6 +159,32 @@ void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
EmitToStreamer(*OutStreamer, TmpInst);
}
+void MSP430AsmPrinter::EmitInterruptVectorSection(MachineFunction &ISR) {
+ MCSection *Cur = OutStreamer->getCurrentSectionOnly();
+ const auto *F = &ISR.getFunction();
+ assert(F->hasFnAttribute("interrupt") &&
+ "Functions with MSP430_INTR CC should have 'interrupt' attribute");
+ StringRef IVIdx = F->getFnAttribute("interrupt").getValueAsString();
+ MCSection *IV = OutStreamer->getContext().getELFSection(
+ "__interrupt_vector_" + IVIdx,
+ ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_EXECINSTR);
+ OutStreamer->SwitchSection(IV);
+
+ const MCSymbol *FunctionSymbol = getSymbol(F);
+ OutStreamer->EmitSymbolValue(FunctionSymbol, TM.getProgramPointerSize());
+ OutStreamer->SwitchSection(Cur);
+}
+
+bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
+ // Emit separate section for an interrupt vector if ISR
+ if (MF.getFunction().getCallingConv() == CallingConv::MSP430_INTR)
+ EmitInterruptVectorSection(MF);
+
+ SetupMachineFunction(MF);
+ EmitFunctionBody();
+ return false;
+}
+
// Force static initialization.
extern "C" void LLVMInitializeMSP430AsmPrinter() {
RegisterAsmPrinter<MSP430AsmPrinter> X(getTheMSP430Target());
OpenPOWER on IntegriCloud