Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
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");
if (F->getCallingConv() != CallingConv::MSP430_INTR) {
report_fatal_error("Functions with 'interrupt' attribute must have msp430_intrcc CC");
}
StringRef IVIdx = F->getFnAttribute("interrupt").getValueAsString();
MCSection *IV = OutStreamer->getContext().getELFSection(
"__interrupt_vector_" + IVIdx,
Expand All @@ -174,8 +175,9 @@ void MSP430AsmPrinter::EmitInterruptVectorSection(MachineFunction &ISR) {

bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Emit separate section for an interrupt vector if ISR
if (MF.getFunction().getCallingConv() == CallingConv::MSP430_INTR)
if (MF.getFunction().hasFnAttribute("interrupt")) {
EmitInterruptVectorSection(MF);
}

SetupMachineFunction(MF);
EmitFunctionBody();
Expand Down
9 changes: 9 additions & 0 deletions llvm/test/CodeGen/MSP430/interrupt.ll
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ entry:
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 #1 = { noinline nounwind optnone }