提交 1ca75068 编写于 作者: D Denis Merigoux 提交者: Eduard-Mihai Burtescu

Generalized AsmDialect for BuilderMethods

上级 b7615389
......@@ -22,7 +22,6 @@
use mir::operand::OperandValue;
use std::ffi::CString;
use syntax::ast::AsmDialect;
use libc::{c_uint, c_char};
// Take an inline assembly expression and splat it out via LLVM
......@@ -82,11 +81,6 @@ pub fn codegen_inline_asm(
_ => Type::struct_(bx.cx, &output_types, false)
};
let dialect = match ia.dialect {
AsmDialect::Att => llvm::AsmDialect::Att,
AsmDialect::Intel => llvm::AsmDialect::Intel,
};
let asm = CString::new(ia.asm.as_str().as_bytes()).unwrap();
let constraint_cstr = CString::new(all_constraints).unwrap();
let r = bx.inline_asm_call(
......@@ -96,7 +90,7 @@ pub fn codegen_inline_asm(
output_type,
ia.volatile,
ia.alignstack,
dialect
ia.dialect
);
if r.is_none() {
return false;
......
......@@ -20,6 +20,7 @@
use rustc::session::{config, Session};
use rustc_data_structures::small_c_str::SmallCStr;
use traits::{self, BuilderMethods};
use syntax;
use std::borrow::Cow;
use std::ops::Range;
......@@ -742,7 +743,7 @@ fn phi(&self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'
fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
inputs: &[&'ll Value], output: &'ll Type,
volatile: bool, alignstack: bool,
dia: AsmDialect) -> Option<&'ll Value> {
dia: syntax::ast::AsmDialect) -> Option<&'ll Value> {
self.count_insn("inlineasm");
let volatile = if volatile { llvm::True }
......@@ -763,7 +764,7 @@ fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
debug!("Constraint verification result: {:?}", constraints_ok);
if constraints_ok {
let v = llvm::LLVMRustInlineAsm(
fty, asm, cons, volatile, alignstack, dia);
fty, asm, cons, volatile, alignstack, AsmDialect::from_generic(dia));
Some(self.call(v, inputs, None))
} else {
// LLVM has detected an issue with our constraints, bail out
......
......@@ -20,6 +20,7 @@
use std::marker::PhantomData;
use traits;
use syntax;
use super::RustString;
......@@ -354,6 +355,15 @@ pub enum AsmDialect {
Intel,
}
impl AsmDialect {
pub fn from_generic(asm : syntax::ast::AsmDialect) -> Self {
match asm {
syntax::ast::AsmDialect::Att => AsmDialect::Att,
syntax::ast::AsmDialect::Intel => AsmDialect::Intel
}
}
}
/// LLVMRustCodeGenOptLevel
#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
......
......@@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use llvm::AsmDialect;
use common::*;
use type_::Type;
use libc::c_char;
......@@ -20,6 +19,7 @@
use std::borrow::Cow;
use std::ops::Range;
use syntax::ast::AsmDialect;
pub struct OperandBundleDef<'a, Value : 'a> {
pub name: &'a str,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册