Skip to content

Commit 98a29dd

Browse files
committed
Add support for inline attribute
1 parent fe242b7 commit 98a29dd

File tree

4 files changed

+12
-34
lines changed

4 files changed

+12
-34
lines changed

gccjit_sys/src/lib.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,22 +253,13 @@ pub enum gcc_jit_comparison
253253
GCC_JIT_COMPARISON_GE
254254
}
255255

256-
#[repr(C)]
257-
pub enum gcc_jit_inline_mode
258-
{
259-
GCC_JIT_INLINE_MODE_DEFAULT,
260-
GCC_JIT_INLINE_MODE_ALWAYS_INLINE,
261-
GCC_JIT_INLINE_MODE_NO_INLINE,
262-
GCC_JIT_INLINE_MODE_INLINE,
263-
}
264-
265256
#[cfg(feature="master")]
266257
#[repr(C)]
267258
pub enum gcc_jit_fn_attribute
268259
{
269-
/*GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
260+
GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
270261
GCC_JIT_FN_ATTRIBUTE_INLINE,
271-
GCC_JIT_FN_ATTRIBUTE_NOINLINE,*/
262+
GCC_JIT_FN_ATTRIBUTE_NOINLINE,
272263
GCC_JIT_FN_ATTRIBUTE_TARGET,
273264
GCC_JIT_FN_ATTRIBUTE_USED,
274265
GCC_JIT_FN_ATTRIBUTE_VISIBILITY,
@@ -577,8 +568,6 @@ extern {
577568

578569
pub fn gcc_jit_context_new_bitcast(ctxt: *mut gcc_jit_context, loc: *mut gcc_jit_location, rvalue: *mut gcc_jit_rvalue, type_: *mut gcc_jit_type) -> *mut gcc_jit_rvalue;
579570

580-
//pub fn gcc_jit_function_set_inline_mode(func: *mut gcc_jit_function, inline_mode: gcc_jit_inline_mode);
581-
582571
pub fn gcc_jit_lvalue_set_register_name(lvalue: *mut gcc_jit_lvalue, reg_name: *const c_char);
583572

584573
pub fn gcc_jit_context_new_struct_constructor(ctxt: *mut gcc_jit_context, loc: *mut gcc_jit_location, typ: *mut gcc_jit_type, arr_length: c_int, fields: *mut *mut gcc_jit_field, values: *mut *mut gcc_jit_rvalue) -> *mut gcc_jit_rvalue;

src/block.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ impl<'ctx> Block<'ctx> {
239239
loc_ptr,
240240
target.ptr);
241241
}
242+
#[cfg(debug_assertions)]
243+
if let Ok(Some(error)) = self.to_object().get_context().get_last_error() {
244+
panic!("{}", error);
245+
}
242246
}
243247

244248
/// Terminates a block by returning from the containing function, setting

src/function.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,12 @@ pub enum FunctionType {
4646
AlwaysInline
4747
}
4848

49-
#[repr(C)]
50-
#[derive(Clone, Copy, Debug)]
51-
pub enum InlineMode {
52-
Default,
53-
AlwaysInline,
54-
NoInline,
55-
Inline,
56-
}
57-
5849
#[cfg(feature="master")]
5950
#[derive(Clone, Copy, Debug)]
6051
pub enum FnAttribute<'a> {
61-
/*AlwaysInline,
52+
AlwaysInline,
6253
Inline,
63-
NoInline,*/
54+
NoInline,
6455
Target(&'a str),
6556
Used,
6657
Visibility(Visibility),
@@ -72,16 +63,16 @@ impl<'a> FnAttribute<'a> {
7263
match *self {
7364
FnAttribute::Target(target) => AttributeValue::String(target),
7465
FnAttribute::Visibility(visibility) => AttributeValue::String(visibility.as_str()),
75-
/*FnAttribute::AlwaysInline | FnAttribute::Inline | FnAttribute::NoInline |*/ FnAttribute::Used =>
66+
FnAttribute::AlwaysInline | FnAttribute::Inline | FnAttribute::NoInline | FnAttribute::Used =>
7667
AttributeValue::None,
7768
}
7869
}
7970

8071
fn to_sys(&self) -> gccjit_sys::gcc_jit_fn_attribute {
8172
match *self {
82-
/*FnAttribute::AlwaysInline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
73+
FnAttribute::AlwaysInline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
8374
FnAttribute::Inline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_INLINE,
84-
FnAttribute::NoInline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_NOINLINE,*/
75+
FnAttribute::NoInline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_NOINLINE,
8576
FnAttribute::Target(_) => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_TARGET,
8677
FnAttribute::Used => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_USED,
8778
FnAttribute::Visibility(_) => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_VISIBILITY,
@@ -122,12 +113,6 @@ impl<'ctx> Function<'ctx> {
122113
}
123114
}
124115

125-
/*pub fn set_inline_mode(&self, inline_mode: InlineMode) {
126-
unsafe {
127-
gccjit_sys::gcc_jit_function_set_inline_mode(self.ptr, std::mem::transmute(inline_mode));
128-
}
129-
}*/
130-
131116
pub fn get_param_count(&self) -> usize {
132117
unsafe {
133118
gccjit_sys::gcc_jit_function_get_param_count(self.ptr) as usize

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ pub use rvalue::{RValue, ToRValue};
5050
pub use parameter::Parameter;
5151
#[cfg(feature="master")]
5252
pub use function::FnAttribute;
53-
pub use function::{Function, FunctionType, InlineMode};
53+
pub use function::{Function, FunctionType};
5454
pub use block::{Block, BinaryOp, UnaryOp, ComparisonOp};

0 commit comments

Comments
 (0)