[llvm] r351345 - [MSP430] Emit a separate section for every interrupt vector
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 17 05:38:27 PST 2019
Merged to 8.0 in r351442.
On Wed, Jan 16, 2019 at 3:07 PM Anton Korobeynikov via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: asl
> Date: Wed Jan 16 06:03:41 2019
> New Revision: 351345
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351345&view=rev
> Log:
> [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", at progbits
> .word %isr%
>
> Patch by Kristina Bessonova!
>
> Differential Revision: https://reviews.llvm.org/D56664
>
> Modified:
> llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp
> llvm/trunk/test/CodeGen/MSP430/2009-12-21-FrameAddr.ll
> llvm/trunk/test/CodeGen/MSP430/fp.ll
> llvm/trunk/test/CodeGen/MSP430/interrupt.ll
>
> Modified: llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp?rev=351345&r1=351344&r2=351345&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp Wed Jan 16 06:03:41 2019
> @@ -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(c
> 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());
>
> Modified: llvm/trunk/test/CodeGen/MSP430/2009-12-21-FrameAddr.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/2009-12-21-FrameAddr.ll?rev=351345&r1=351344&r2=351345&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/MSP430/2009-12-21-FrameAddr.ll (original)
> +++ llvm/trunk/test/CodeGen/MSP430/2009-12-21-FrameAddr.ll Wed Jan 16 06:03:41 2019
> @@ -3,7 +3,7 @@
> target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"
> target triple = "msp430-unknown-linux-gnu"
>
> -define msp430_intrcc void @foo() nounwind {
> +define msp430_intrcc void @foo() nounwind #0 {
> entry:
> %fa = call i8* @llvm.frameaddress(i32 0)
> store i8 0, i8* %fa
> @@ -11,3 +11,5 @@ entry:
> }
>
> declare i8* @llvm.frameaddress(i32)
> +
> +attributes #0 = { noinline nounwind optnone "interrupt"="2" }
>
> Modified: llvm/trunk/test/CodeGen/MSP430/fp.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/fp.ll?rev=351345&r1=351344&r2=351345&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/MSP430/fp.ll (original)
> +++ llvm/trunk/test/CodeGen/MSP430/fp.ll Wed Jan 16 06:03:41 2019
> @@ -27,3 +27,5 @@ define msp430_intrcc void @fpb_alloced()
> call void asm sideeffect "nop", "r"(i8 0)
> ret void
> }
> +
> +attributes #0 = { noinline nounwind optnone "interrupt"="2" }
>
> Modified: llvm/trunk/test/CodeGen/MSP430/interrupt.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/interrupt.ll?rev=351345&r1=351344&r2=351345&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/MSP430/interrupt.ll (original)
> +++ llvm/trunk/test/CodeGen/MSP430/interrupt.ll Wed Jan 16 06:03:41 2019
> @@ -13,6 +13,9 @@ target triple = "msp430-generic-generic"
> ; instruction RETI, which restores the SR register and branches to the PC where
> ; the interrupt occurred.
>
> +; CHECK: .section __interrupt_vector_2,"ax", at progbits
> +; CHECK-NEXT: .short ISR
> +
> @g = global float 0.0
>
> define msp430_intrcc void @ISR() #0 {
> @@ -47,3 +50,4 @@ entry:
> ret void
> }
>
> +attributes #0 = { noinline nounwind optnone "interrupt"="2" }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list