Skip to content

Commit 6296d52

Browse files
author
Jorge Aparicio
committed
calling convention for MSP430 interrupts
This calling convention is used to define interrup handlers on MSP430 microcontrollers. Usage looks like this: ``` rust #[no_mangle] #[link_section = "__interrupt_vector_10"] pub static TIM0_VECTOR: unsafe extern "msp430-interrupt" fn() = tim0; unsafe extern "msp430-interrupt" fn tim0() { P1OUT.write(0x00); } ``` which generates the following assembly: ``` asm Disassembly of section __interrupt_vector_10: 0000fff2 <TIM0_VECTOR>: fff2: 10 c0 interrupt service routine at 0xc010 Disassembly of section .text: 0000c010 <_ZN3msp4tim017h3193b957fd6a4fd4E>: c010: c2 43 21 00 mov.b #0, &0x0021 ;r3 As==00 c014: 00 13 reti ... ```
1 parent c8af93f commit 6296d52

File tree

6 files changed

+19
-1
lines changed

6 files changed

+19
-1
lines changed

src/librustc_llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub enum CallConv {
4242
X86StdcallCallConv = 64,
4343
X86FastcallCallConv = 65,
4444
ArmAapcsCallConv = 67,
45+
Msp430Intr = 69,
4546
PtxKernel = 71,
4647
X86_64_SysV = 78,
4748
X86_64_Win64 = 79,

src/librustc_trans/abi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ impl FnType {
356356
SysV64 => llvm::X86_64_SysV,
357357
Aapcs => llvm::ArmAapcsCallConv,
358358
PtxKernel => llvm::PtxKernel,
359+
Msp430Interrupt => llvm::Msp430Intr,
359360

360361
// These API constants ought to be more specific...
361362
Cdecl => llvm::CCallConv,

src/libsyntax/abi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub enum Abi {
4242
Win64,
4343
SysV64,
4444
PtxKernel,
45+
Msp430Interrupt,
4546

4647
// Multiplatform / generic ABIs
4748
Rust,
@@ -85,6 +86,7 @@ const AbiDatas: &'static [AbiData] = &[
8586
AbiData {abi: Abi::Win64, name: "win64", generic: false },
8687
AbiData {abi: Abi::SysV64, name: "sysv64", generic: false },
8788
AbiData {abi: Abi::PtxKernel, name: "ptx-kernel", generic: false },
89+
AbiData {abi: Abi::Msp430Interrupt, name: "msp430-interrupt", generic: false },
8890

8991
// Cross-platform ABIs
9092
AbiData {abi: Abi::Rust, name: "Rust", generic: true },

src/libsyntax/feature_gate.rs

+7
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ declare_features! (
321321

322322
// Allows attributes on struct literal fields.
323323
(active, struct_field_attributes, "1.16.0", Some(38814)),
324+
325+
// `extern "msp430-interrupt" fn()`
326+
(active, abi_msp430_interrupt, "1.16.0", Some(38487)),
324327
);
325328

326329
declare_features! (
@@ -995,6 +998,10 @@ impl<'a> PostExpansionVisitor<'a> {
995998
gate_feature_post!(&self, abi_unadjusted, span,
996999
"unadjusted ABI is an implementation detail and perma-unstable");
9971000
},
1001+
Abi::Msp430Interrupt => {
1002+
gate_feature_post!(&self, abi_msp430_interrupt, span,
1003+
"msp430-interrupt ABI is experimental and subject to change");
1004+
},
9981005
// Stable
9991006
Abi::Cdecl |
10001007
Abi::Stdcall |

src/test/compile-fail/feature-gate-abi.rs

+7
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
1717
extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental
1818
extern "vectorcall" fn f3() {} //~ ERROR vectorcall is experimental and subject to change
1919
extern "rust-call" fn f4() {} //~ ERROR rust-call ABI is subject to change
20+
extern "msp430-interrupt" fn f5() {} //~ ERROR msp430-interrupt ABI is experimental
2021

2122
// Methods in trait definition
2223
trait Tr {
2324
extern "rust-intrinsic" fn m1(); //~ ERROR intrinsics are subject to change
2425
extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental
2526
extern "vectorcall" fn m3(); //~ ERROR vectorcall is experimental and subject to change
2627
extern "rust-call" fn m4(); //~ ERROR rust-call ABI is subject to change
28+
extern "msp430-interrupt" fn m5(); //~ ERROR msp430-interrupt ABI is experimental
2729

2830
extern "rust-intrinsic" fn dm1() {} //~ ERROR intrinsics are subject to change
2931
extern "platform-intrinsic" fn dm2() {} //~ ERROR platform intrinsics are experimental
3032
extern "vectorcall" fn dm3() {} //~ ERROR vectorcall is experimental and subject to change
3133
extern "rust-call" fn dm4() {} //~ ERROR rust-call ABI is subject to change
34+
extern "msp430-interrupt" fn dm5() {} //~ ERROR msp430-interrupt ABI is experimental
3235
}
3336

3437
struct S;
@@ -39,6 +42,7 @@ impl Tr for S {
3942
extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental
4043
extern "vectorcall" fn m3() {} //~ ERROR vectorcall is experimental and subject to change
4144
extern "rust-call" fn m4() {} //~ ERROR rust-call ABI is subject to change
45+
extern "msp430-interrupt" fn m5() {} //~ ERROR msp430-interrupt ABI is experimental
4246
}
4347

4448
// Methods in inherent impl
@@ -47,18 +51,21 @@ impl S {
4751
extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental
4852
extern "vectorcall" fn im3() {} //~ ERROR vectorcall is experimental and subject to change
4953
extern "rust-call" fn im4() {} //~ ERROR rust-call ABI is subject to change
54+
extern "msp430-interrupt" fn im5() {} //~ ERROR msp430-interrupt ABI is experimental
5055
}
5156

5257
// Function pointer types
5358
type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change
5459
type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are experimental
5560
type A3 = extern "vectorcall" fn(); //~ ERROR vectorcall is experimental and subject to change
5661
type A4 = extern "rust-call" fn(); //~ ERROR rust-call ABI is subject to change
62+
type A5 = extern "msp430-interrupt" fn(); //~ ERROR msp430-interrupt ABI is experimental
5763

5864
// Foreign modules
5965
extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change
6066
extern "platform-intrinsic" {} //~ ERROR platform intrinsics are experimental
6167
extern "vectorcall" {} //~ ERROR vectorcall is experimental and subject to change
6268
extern "rust-call" {} //~ ERROR rust-call ABI is subject to change
69+
extern "msp430-interrupt" {} //~ ERROR msp430-interrupt ABI is experimental
6370

6471
fn main() {}

src/test/ui/codemap_tests/unicode.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: invalid ABI: expected one of [cdecl, stdcall, fastcall, vectorcall, aapcs, win64, sysv64, ptx-kernel, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted], found `路濫狼á́́`
1+
error: invalid ABI: expected one of [cdecl, stdcall, fastcall, vectorcall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted], found `路濫狼á́́`
22
--> $DIR/unicode.rs:11:8
33
|
44
11 | extern "路濫狼á́́" fn foo() {}

0 commit comments

Comments
 (0)