Retain assembly operands span when lowering AST to HIR
This commit is contained in:
parent
0f6f2d681b
commit
91fe548825
13 changed files with 18 additions and 20 deletions
|
@ -1307,7 +1307,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
hir::InlineAsmOperand::Sym { expr: self.lower_expr_mut(expr) }
|
||||
}
|
||||
};
|
||||
Some(op)
|
||||
Some((op, *op_sp))
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -1326,7 +1326,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
} = *p
|
||||
{
|
||||
let op_sp = asm.operands[operand_idx].1;
|
||||
match &operands[operand_idx] {
|
||||
match &operands[operand_idx].0 {
|
||||
hir::InlineAsmOperand::In { reg, .. }
|
||||
| hir::InlineAsmOperand::Out { reg, .. }
|
||||
| hir::InlineAsmOperand::InOut { reg, .. }
|
||||
|
@ -1385,8 +1385,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
let mut used_input_regs = FxHashMap::default();
|
||||
let mut used_output_regs = FxHashMap::default();
|
||||
let mut required_features: Vec<&str> = vec![];
|
||||
for (idx, op) in operands.iter().enumerate() {
|
||||
let op_sp = asm.operands[idx].1;
|
||||
for (idx, &(ref op, op_sp)) in operands.iter().enumerate() {
|
||||
if let Some(reg) = op.reg() {
|
||||
// Make sure we don't accidentally carry features from the
|
||||
// previous iteration.
|
||||
|
@ -1458,8 +1457,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
skip = true;
|
||||
|
||||
let idx2 = *o.get();
|
||||
let op2 = &operands[idx2];
|
||||
let op_sp2 = asm.operands[idx2].1;
|
||||
let &(ref op2, op_sp2) = &operands[idx2];
|
||||
let reg2 = match op2.reg() {
|
||||
Some(asm::InlineAsmRegOrRegClass::Reg(r)) => r,
|
||||
_ => unreachable!(),
|
||||
|
|
|
@ -14,7 +14,7 @@ macro_rules! arena_types {
|
|||
// HIR types
|
||||
[few] hir_krate: rustc_hir::Crate<$tcx>,
|
||||
[] arm: rustc_hir::Arm<$tcx>,
|
||||
[] asm_operand: rustc_hir::InlineAsmOperand<$tcx>,
|
||||
[] asm_operand: (rustc_hir::InlineAsmOperand<$tcx>, Span),
|
||||
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
|
||||
[] attribute: rustc_ast::Attribute,
|
||||
[] block: rustc_hir::Block<$tcx>,
|
||||
|
|
|
@ -2143,7 +2143,7 @@ impl<'hir> InlineAsmOperand<'hir> {
|
|||
#[derive(Debug, HashStable_Generic)]
|
||||
pub struct InlineAsm<'hir> {
|
||||
pub template: &'hir [InlineAsmTemplatePiece],
|
||||
pub operands: &'hir [InlineAsmOperand<'hir>],
|
||||
pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
|
||||
pub options: InlineAsmOptions,
|
||||
pub line_spans: &'hir [Span],
|
||||
}
|
||||
|
|
|
@ -1191,7 +1191,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
walk_list!(visitor, visit_expr, optional_expression);
|
||||
}
|
||||
ExprKind::InlineAsm(ref asm) => {
|
||||
for op in asm.operands {
|
||||
for (op, _op_sp) in asm.operands {
|
||||
match op {
|
||||
InlineAsmOperand::In { expr, .. }
|
||||
| InlineAsmOperand::InOut { expr, .. }
|
||||
|
|
|
@ -1462,7 +1462,7 @@ impl<'a> State<'a> {
|
|||
|
||||
let mut args = vec![];
|
||||
args.push(AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&a.template)));
|
||||
args.extend(a.operands.iter().map(|o| AsmArg::Operand(o)));
|
||||
args.extend(a.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
|
||||
if !a.options.is_empty() {
|
||||
args.push(AsmArg::Options(a.options));
|
||||
}
|
||||
|
|
|
@ -408,7 +408,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
operands: asm
|
||||
.operands
|
||||
.iter()
|
||||
.map(|op| {
|
||||
.map(|(op, _op_sp)| {
|
||||
match *op {
|
||||
hir::InlineAsmOperand::In { reg, ref expr } => {
|
||||
InlineAsmOperand::In { reg, expr: expr.to_ref() }
|
||||
|
|
|
@ -347,7 +347,7 @@ impl ExprVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn check_asm(&self, asm: &hir::InlineAsm<'tcx>) {
|
||||
for (idx, op) in asm.operands.iter().enumerate() {
|
||||
for (idx, (op, _op_sp)) in asm.operands.iter().enumerate() {
|
||||
match *op {
|
||||
hir::InlineAsmOperand::In { reg, ref expr } => {
|
||||
self.check_asm_operand_type(idx, reg, expr, asm.template, None);
|
||||
|
|
|
@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
};
|
||||
|
||||
// Do a first pass for writing outputs only
|
||||
for op in asm.operands.iter().rev() {
|
||||
for (op, _op_sp) in asm.operands.iter().rev() {
|
||||
match op {
|
||||
hir::InlineAsmOperand::In { .. }
|
||||
| hir::InlineAsmOperand::Const { .. }
|
||||
|
@ -1197,7 +1197,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
// Then do a second pass for inputs
|
||||
let mut succ = succ;
|
||||
for op in asm.operands.iter().rev() {
|
||||
for (op, _op_sp) in asm.operands.iter().rev() {
|
||||
match op {
|
||||
hir::InlineAsmOperand::In { expr, .. }
|
||||
| hir::InlineAsmOperand::Const { expr, .. }
|
||||
|
@ -1454,7 +1454,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||
}
|
||||
|
||||
hir::ExprKind::InlineAsm(ref asm) => {
|
||||
for op in asm.operands {
|
||||
for (op, _op_sp) in asm.operands {
|
||||
match op {
|
||||
hir::InlineAsmOperand::Out { expr, .. } => {
|
||||
if let Some(expr) = expr {
|
||||
|
|
|
@ -1929,7 +1929,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn check_expr_asm(&self, asm: &'tcx hir::InlineAsm<'tcx>) -> Ty<'tcx> {
|
||||
for op in asm.operands {
|
||||
for (op, _op_sp) in asm.operands {
|
||||
match op {
|
||||
hir::InlineAsmOperand::In { expr, .. } | hir::InlineAsmOperand::Const { expr } => {
|
||||
self.check_expr_asm_operand(expr, true);
|
||||
|
|
|
@ -243,7 +243,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::ExprKind::InlineAsm(ref asm) => {
|
||||
for op in asm.operands {
|
||||
for (op, _op_sp) in asm.operands {
|
||||
match op {
|
||||
hir::InlineAsmOperand::In { expr, .. }
|
||||
| hir::InlineAsmOperand::Const { expr, .. }
|
||||
|
|
|
@ -768,7 +768,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
|
|||
ExprKind::InlineAsm(ref asm) => asm
|
||||
.operands
|
||||
.iter()
|
||||
.map(|o| match o {
|
||||
.map(|(o, _)| match o {
|
||||
InlineAsmOperand::In { expr, .. }
|
||||
| InlineAsmOperand::InOut { expr, .. }
|
||||
| InlineAsmOperand::Const { expr }
|
||||
|
|
|
@ -517,7 +517,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
asm.options.hash(&mut self.s);
|
||||
for op in asm.operands {
|
||||
for (op, _op_sp) in asm.operands {
|
||||
match op {
|
||||
InlineAsmOperand::In { reg, expr } => {
|
||||
reg.hash(&mut self.s);
|
||||
|
|
|
@ -293,7 +293,7 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
|
|||
println!("{}template: {}", ind, InlineAsmTemplatePiece::to_string(asm.template));
|
||||
println!("{}options: {:?}", ind, asm.options);
|
||||
println!("{}operands:", ind);
|
||||
for op in asm.operands {
|
||||
for (op, _op_sp) in asm.operands {
|
||||
match op {
|
||||
hir::InlineAsmOperand::In { expr, .. }
|
||||
| hir::InlineAsmOperand::InOut { expr, .. }
|
||||
|
|
Loading…
Add table
Reference in a new issue