Skip to content
Snippets Groups Projects

Add more LLVM attributes

Merged rarbore2 requested to merge llvm_attrs into main
+ 11
8
@@ -68,7 +68,7 @@ impl<'a> CPUContext<'a> {
@@ -68,7 +68,7 @@ impl<'a> CPUContext<'a> {
if self.types[return_type.idx()].is_primitive() {
if self.types[return_type.idx()].is_primitive() {
write!(
write!(
w,
w,
"define dso_local {} @{}_{}(",
"define dso_local nounwind nosync willreturn norecurse {} @{}_{}(",
self.get_type(return_type),
self.get_type(return_type),
self.module_name,
self.module_name,
self.function.name,
self.function.name,
@@ -76,7 +76,7 @@ impl<'a> CPUContext<'a> {
@@ -76,7 +76,7 @@ impl<'a> CPUContext<'a> {
} else {
} else {
write!(
write!(
w,
w,
"define dso_local nonnull noundef {} @{}_{}(",
"define dso_local nonnull noundef nounwind nosync willreturn norecurse {} @{}_{}(",
self.get_type(return_type),
self.get_type(return_type),
self.module_name,
self.module_name,
self.function.name,
self.function.name,
@@ -96,7 +96,7 @@ impl<'a> CPUContext<'a> {
@@ -96,7 +96,7 @@ impl<'a> CPUContext<'a> {
)?;
)?;
write!(
write!(
w,
w,
"define dso_local void @{}_{}(",
"define dso_local nounwind nosync willreturn norecurse void @{}_{}(",
self.module_name, self.function.name,
self.module_name, self.function.name,
)?;
)?;
}
}
@@ -346,7 +346,7 @@ impl<'a> CPUContext<'a> {
@@ -346,7 +346,7 @@ impl<'a> CPUContext<'a> {
let offset = offsets[&id].0;
let offset = offsets[&id].0;
write!(
write!(
body,
body,
" {} = getelementptr i8, ptr %backing, i64 %dc{}\n",
" {} = getelementptr inbounds i8, ptr %backing, i64 %dc{}\n",
self.get_value(id, false),
self.get_value(id, false),
offset.idx()
offset.idx()
)?;
)?;
@@ -473,11 +473,14 @@ impl<'a> CPUContext<'a> {
@@ -473,11 +473,14 @@ impl<'a> CPUContext<'a> {
let opcode = match (op, op_ty) {
let opcode = match (op, op_ty) {
(BinaryOperator::Add, OpTy::Float) => "fadd",
(BinaryOperator::Add, OpTy::Float) => "fadd",
(BinaryOperator::Add, _) => "add",
(BinaryOperator::Add, OpTy::Unsigned) => "add nuw",
 
(BinaryOperator::Add, OpTy::Signed) => "add nsw",
(BinaryOperator::Sub, OpTy::Float) => "fsub",
(BinaryOperator::Sub, OpTy::Float) => "fsub",
(BinaryOperator::Sub, _) => "sub",
(BinaryOperator::Sub, OpTy::Unsigned) => "sub nuw",
 
(BinaryOperator::Sub, OpTy::Signed) => "sub nsw",
(BinaryOperator::Mul, OpTy::Float) => "fmul",
(BinaryOperator::Mul, OpTy::Float) => "fmul",
(BinaryOperator::Mul, _) => "mul",
(BinaryOperator::Mul, OpTy::Unsigned) => "mul nuw",
 
(BinaryOperator::Mul, OpTy::Signed) => "mul nsw",
(BinaryOperator::Div, OpTy::Float) => "fdiv",
(BinaryOperator::Div, OpTy::Float) => "fdiv",
(BinaryOperator::Div, OpTy::Unsigned) => "udiv",
(BinaryOperator::Div, OpTy::Unsigned) => "udiv",
(BinaryOperator::Div, OpTy::Signed) => "sdiv",
(BinaryOperator::Div, OpTy::Signed) => "sdiv",
@@ -1005,7 +1008,7 @@ impl<'a> CPUContext<'a> {
@@ -1005,7 +1008,7 @@ impl<'a> CPUContext<'a> {
let name = format!("%gep.{}", Self::gen_filler_id());
let name = format!("%gep.{}", Self::gen_filler_id());
write!(
write!(
body,
body,
" {} = getelementptr i8, ptr {}, i64 {}\n",
" {} = getelementptr inbounds i8, ptr {}, i64 {}\n",
name, ptr, size
name, ptr, size
)?;
)?;
Ok(name)
Ok(name)
Loading