1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[MSP430] Allow msp430_intrcc functions to not have interrupt attribute.

Summary:
Useful in case you want to have control over interrupt vector generation.
For example in Rust language we have an arrangement where all unhandled
ISR vectors gets mapped to a single default handler function. Which is
hard to implement when LLVM tries to generate vectors on its own.

Reviewers: asl, krisb

Subscribers: hiraditya, JDevlieghere, awygle, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67313

llvm-svn: 372910
This commit is contained in:
Vadzim Dambrouski 2019-09-25 18:58:07 +00:00
parent d1d0a0237f
commit acacd8b14d
2 changed files with 14 additions and 3 deletions

View File

@ -159,8 +159,9 @@ void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
void MSP430AsmPrinter::EmitInterruptVectorSection(MachineFunction &ISR) { void MSP430AsmPrinter::EmitInterruptVectorSection(MachineFunction &ISR) {
MCSection *Cur = OutStreamer->getCurrentSectionOnly(); MCSection *Cur = OutStreamer->getCurrentSectionOnly();
const auto *F = &ISR.getFunction(); const auto *F = &ISR.getFunction();
assert(F->hasFnAttribute("interrupt") && if (F->getCallingConv() != CallingConv::MSP430_INTR) {
"Functions with MSP430_INTR CC should have 'interrupt' attribute"); report_fatal_error("Functions with 'interrupt' attribute must have msp430_intrcc CC");
}
StringRef IVIdx = F->getFnAttribute("interrupt").getValueAsString(); StringRef IVIdx = F->getFnAttribute("interrupt").getValueAsString();
MCSection *IV = OutStreamer->getContext().getELFSection( MCSection *IV = OutStreamer->getContext().getELFSection(
"__interrupt_vector_" + IVIdx, "__interrupt_vector_" + IVIdx,
@ -174,8 +175,9 @@ void MSP430AsmPrinter::EmitInterruptVectorSection(MachineFunction &ISR) {
bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) { bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Emit separate section for an interrupt vector if ISR // Emit separate section for an interrupt vector if ISR
if (MF.getFunction().getCallingConv() == CallingConv::MSP430_INTR) if (MF.getFunction().hasFnAttribute("interrupt")) {
EmitInterruptVectorSection(MF); EmitInterruptVectorSection(MF);
}
SetupMachineFunction(MF); SetupMachineFunction(MF);
EmitFunctionBody(); EmitFunctionBody();

View File

@ -50,4 +50,13 @@ entry:
ret void ret void
} }
; Functions without 'interrupt' attribute don't get a vector section.
; CHECK-NOT: __interrupt_vector
; CHECK-LABEL: NMI:
; CHECK: reti
define msp430_intrcc void @NMI() #1 {
ret void
}
attributes #0 = { noinline nounwind optnone "interrupt"="2" } attributes #0 = { noinline nounwind optnone "interrupt"="2" }
attributes #1 = { noinline nounwind optnone }