-
-
Save Amanieu/ebd5b82cd0b4e492b1d8ab8dc0649c37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn propagate_through_expr(&mut self, expr: &Expr<'_>, succ: LiveNode) -> LiveNode { | |
match expr.kind { | |
hir::ExprKind::InlineAsm(ref asm) => { | |
// Handle non-returning asm | |
let mut succ = if asm.options.contains(InlineAsmOptions::NORETURN) { | |
self.s.exit_ln | |
} else { | |
succ | |
}; | |
// Do a first pass for writing outputs only | |
for (op, _) in asm.operands.iter().rev() { | |
match op { | |
hir::InlineAsmOperand::In { expr, .. } | |
| hir::InlineAsmOperand::Const { expr, .. } | |
| hir::InlineAsmOperand::Sym { expr, .. } => {} | |
hir::InlineAsmOperand::Out { expr, .. } => { | |
if let Some(expr) = expr { | |
succ = self.write_place(expr, succ, ACC_WRITE); | |
} | |
} | |
hir::InlineAsmOperand::InOut { expr, .. } => { | |
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE); | |
} | |
hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => { | |
if let Some(expr) = out_expr { | |
succ = self.write_place(expr, succ, ACC_WRITE); | |
} | |
} | |
} | |
} | |
// Then do a second pass for inputs | |
let mut succ = succ; | |
for (op, _) in asm.operands.iter().rev() { | |
match op { | |
hir::InlineAsmOperand::In { expr, .. } | |
| hir::InlineAsmOperand::Const { expr, .. } | |
| hir::InlineAsmOperand::Sym { expr, .. } => { | |
succ = self.propagate_through_expr(expr, succ) | |
} | |
hir::InlineAsmOperand::Out { expr, .. } => { | |
if let Some(expr) = expr { | |
succ = self.propagate_through_place_components(expr, succ); | |
} | |
} | |
hir::InlineAsmOperand::InOut { expr, .. } => { | |
succ = self.propagate_through_place_components(expr, succ); | |
} | |
hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => { | |
if let Some(expr) = out_expr { | |
succ = self.propagate_through_place_components(expr, succ); | |
} | |
succ = self.propagate_through_expr(in_expr, succ); | |
} | |
} | |
} | |
succ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment