Generalized AsmDialect for BuilderMethods
This commit is contained in:
parent
b761538997
commit
1ca750683e
4 changed files with 15 additions and 10 deletions
|
|
@ -22,7 +22,6 @@ use mir::place::PlaceRef;
|
|||
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::ty::layout::{Align, Size};
|
|||
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 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, 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 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
|
|||
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 libc::{c_ulonglong, c_void};
|
|||
|
||||
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 value::Value;
|
|||
|
||||
use std::borrow::Cow;
|
||||
use std::ops::Range;
|
||||
use syntax::ast::AsmDialect;
|
||||
|
||||
pub struct OperandBundleDef<'a, Value : 'a> {
|
||||
pub name: &'a str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue