Skip to content

Commit 000b36c

Browse files
committed
Remove deprecated LLVM-style inline assembly
1 parent 72e74d7 commit 000b36c

File tree

68 files changed

+27
-1132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+27
-1132
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ impl Expr {
12661266
ExprKind::Break(..) => ExprPrecedence::Break,
12671267
ExprKind::Continue(..) => ExprPrecedence::Continue,
12681268
ExprKind::Ret(..) => ExprPrecedence::Ret,
1269-
ExprKind::InlineAsm(..) | ExprKind::LlvmInlineAsm(..) => ExprPrecedence::InlineAsm,
1269+
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
12701270
ExprKind::MacCall(..) => ExprPrecedence::Mac,
12711271
ExprKind::Struct(..) => ExprPrecedence::Struct,
12721272
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
@@ -1423,8 +1423,6 @@ pub enum ExprKind {
14231423

14241424
/// Output of the `asm!()` macro.
14251425
InlineAsm(P<InlineAsm>),
1426-
/// Output of the `llvm_asm!()` macro.
1427-
LlvmInlineAsm(P<LlvmInlineAsm>),
14281426

14291427
/// A macro invocation; pre-expansion.
14301428
MacCall(MacCall),
@@ -2076,41 +2074,6 @@ pub struct InlineAsm {
20762074
pub line_spans: Vec<Span>,
20772075
}
20782076

2079-
/// Inline assembly dialect.
2080-
///
2081-
/// E.g., `"intel"` as in `llvm_asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`.
2082-
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Copy, Hash, HashStable_Generic)]
2083-
pub enum LlvmAsmDialect {
2084-
Att,
2085-
Intel,
2086-
}
2087-
2088-
/// LLVM-style inline assembly.
2089-
///
2090-
/// E.g., `"={eax}"(result)` as in `llvm_asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`.
2091-
#[derive(Clone, Encodable, Decodable, Debug)]
2092-
pub struct LlvmInlineAsmOutput {
2093-
pub constraint: Symbol,
2094-
pub expr: P<Expr>,
2095-
pub is_rw: bool,
2096-
pub is_indirect: bool,
2097-
}
2098-
2099-
/// LLVM-style inline assembly.
2100-
///
2101-
/// E.g., `llvm_asm!("NOP");`.
2102-
#[derive(Clone, Encodable, Decodable, Debug)]
2103-
pub struct LlvmInlineAsm {
2104-
pub asm: Symbol,
2105-
pub asm_str_style: StrStyle,
2106-
pub outputs: Vec<LlvmInlineAsmOutput>,
2107-
pub inputs: Vec<(Symbol, P<Expr>)>,
2108-
pub clobbers: Vec<Symbol>,
2109-
pub volatile: bool,
2110-
pub alignstack: bool,
2111-
pub dialect: LlvmAsmDialect,
2112-
}
2113-
21142077
/// A parameter in a function header.
21152078
///
21162079
/// E.g., `bar: usize` as in `fn foo(bar: usize)`.

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,23 +1350,6 @@ pub fn noop_visit_expr<T: MutVisitor>(
13501350
visit_opt(expr, |expr| vis.visit_expr(expr));
13511351
}
13521352
ExprKind::InlineAsm(asm) => noop_visit_inline_asm(asm, vis),
1353-
ExprKind::LlvmInlineAsm(asm) => {
1354-
let LlvmInlineAsm {
1355-
asm: _,
1356-
asm_str_style: _,
1357-
outputs,
1358-
inputs,
1359-
clobbers: _,
1360-
volatile: _,
1361-
alignstack: _,
1362-
dialect: _,
1363-
} = asm.deref_mut();
1364-
for out in outputs {
1365-
let LlvmInlineAsmOutput { constraint: _, expr, is_rw: _, is_indirect: _ } = out;
1366-
vis.visit_expr(expr);
1367-
}
1368-
visit_vec(inputs, |(_c, expr)| vis.visit_expr(expr));
1369-
}
13701353
ExprKind::MacCall(mac) => vis.visit_mac_call(mac),
13711354
ExprKind::Struct(se) => {
13721355
let StructExpr { qself, path, fields, rest } = se.deref_mut();

compiler/rustc_ast/src/visit.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,6 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
864864
ExprKind::MacCall(ref mac) => visitor.visit_mac_call(mac),
865865
ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression),
866866
ExprKind::InlineAsm(ref asm) => walk_inline_asm(visitor, asm),
867-
ExprKind::LlvmInlineAsm(ref ia) => {
868-
for &(_, ref input) in &ia.inputs {
869-
visitor.visit_expr(input)
870-
}
871-
for output in &ia.outputs {
872-
visitor.visit_expr(&output.expr)
873-
}
874-
}
875867
ExprKind::Yield(ref optional_expression) => {
876868
walk_list!(visitor, visit_expr, optional_expression);
877869
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
226226
ExprKind::InlineAsm(ref asm) => {
227227
hir::ExprKind::InlineAsm(self.lower_inline_asm(e.span, asm))
228228
}
229-
ExprKind::LlvmInlineAsm(ref asm) => self.lower_expr_llvm_asm(asm),
230229
ExprKind::Struct(ref se) => {
231230
let rest = match &se.rest {
232231
StructRest::Base(e) => Some(self.lower_expr(e)),
@@ -1284,38 +1283,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
12841283
result
12851284
}
12861285

1287-
fn lower_expr_llvm_asm(&mut self, asm: &LlvmInlineAsm) -> hir::ExprKind<'hir> {
1288-
let inner = hir::LlvmInlineAsmInner {
1289-
inputs: asm.inputs.iter().map(|&(c, _)| c).collect(),
1290-
outputs: asm
1291-
.outputs
1292-
.iter()
1293-
.map(|out| hir::LlvmInlineAsmOutput {
1294-
constraint: out.constraint,
1295-
is_rw: out.is_rw,
1296-
is_indirect: out.is_indirect,
1297-
span: self.lower_span(out.expr.span),
1298-
})
1299-
.collect(),
1300-
asm: asm.asm,
1301-
asm_str_style: asm.asm_str_style,
1302-
clobbers: asm.clobbers.clone(),
1303-
volatile: asm.volatile,
1304-
alignstack: asm.alignstack,
1305-
dialect: asm.dialect,
1306-
};
1307-
let hir_asm = hir::LlvmInlineAsm {
1308-
inner,
1309-
inputs_exprs: self.arena.alloc_from_iter(
1310-
asm.inputs.iter().map(|&(_, ref input)| self.lower_expr_mut(input)),
1311-
),
1312-
outputs_exprs: self
1313-
.arena
1314-
.alloc_from_iter(asm.outputs.iter().map(|out| self.lower_expr_mut(&out.expr))),
1315-
};
1316-
hir::ExprKind::LlvmInlineAsm(self.arena.alloc(hir_asm))
1317-
}
1318-
13191286
fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> {
13201287
hir::ExprField {
13211288
hir_id: self.next_id(),

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -960,15 +960,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
960960
return;
961961
}
962962
ExprKind::Let(..) if !let_allowed => this.ban_let_expr(expr),
963-
ExprKind::LlvmInlineAsm(..) if !this.session.target.allow_asm => {
964-
struct_span_err!(
965-
this.session,
966-
expr.span,
967-
E0472,
968-
"llvm_asm! is unsupported on this target"
969-
)
970-
.emit();
971-
}
972963
ExprKind::Match(expr, arms) => {
973964
this.visit_expr(expr);
974965
for arm in arms {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,62 +2168,6 @@ impl<'a> State<'a> {
21682168
self.word("asm!");
21692169
self.print_inline_asm(a);
21702170
}
2171-
ast::ExprKind::LlvmInlineAsm(ref a) => {
2172-
self.word("llvm_asm!");
2173-
self.popen();
2174-
self.print_symbol(a.asm, a.asm_str_style);
2175-
self.word_space(":");
2176-
2177-
self.commasep(Inconsistent, &a.outputs, |s, out| {
2178-
let constraint = out.constraint.as_str();
2179-
let mut ch = constraint.chars();
2180-
match ch.next() {
2181-
Some('=') if out.is_rw => {
2182-
s.print_string(&format!("+{}", ch.as_str()), ast::StrStyle::Cooked)
2183-
}
2184-
_ => s.print_string(&constraint, ast::StrStyle::Cooked),
2185-
}
2186-
s.popen();
2187-
s.print_expr(&out.expr);
2188-
s.pclose();
2189-
});
2190-
self.space();
2191-
self.word_space(":");
2192-
2193-
self.commasep(Inconsistent, &a.inputs, |s, &(co, ref o)| {
2194-
s.print_symbol(co, ast::StrStyle::Cooked);
2195-
s.popen();
2196-
s.print_expr(o);
2197-
s.pclose();
2198-
});
2199-
self.space();
2200-
self.word_space(":");
2201-
2202-
self.commasep(Inconsistent, &a.clobbers, |s, &co| {
2203-
s.print_symbol(co, ast::StrStyle::Cooked);
2204-
});
2205-
2206-
let mut options = vec![];
2207-
if a.volatile {
2208-
options.push("volatile");
2209-
}
2210-
if a.alignstack {
2211-
options.push("alignstack");
2212-
}
2213-
if a.dialect == ast::LlvmAsmDialect::Intel {
2214-
options.push("intel");
2215-
}
2216-
2217-
if !options.is_empty() {
2218-
self.space();
2219-
self.word_space(":");
2220-
self.commasep(Inconsistent, &options, |s, &co| {
2221-
s.print_string(co, ast::StrStyle::Cooked);
2222-
});
2223-
}
2224-
2225-
self.pclose();
2226-
}
22272171
ast::ExprKind::MacCall(ref m) => self.print_mac(m),
22282172
ast::ExprKind::Paren(ref e) => {
22292173
self.popen();

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_mir_dataflow::ResultsVisitable;
88
use rustc_mir_dataflow::{self, fmt::DebugWithContext, CallReturnPlaces, GenKill};
99
use rustc_mir_dataflow::{Analysis, Direction, Results};
1010
use std::fmt;
11-
use std::iter;
1211

1312
use crate::{
1413
places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext, ToRegionVid,
@@ -385,14 +384,6 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
385384
self.kill_borrows_on_place(trans, Place::from(local));
386385
}
387386

388-
mir::StatementKind::LlvmInlineAsm(ref asm) => {
389-
for (output, kind) in iter::zip(&*asm.outputs, &asm.asm.outputs) {
390-
if !kind.is_indirect && !kind.is_rw {
391-
self.kill_borrows_on_place(trans, *output);
392-
}
393-
}
394-
}
395-
396387
mir::StatementKind::FakeRead(..)
397388
| mir::StatementKind::SetDiscriminant { .. }
398389
| mir::StatementKind::StorageLive(..)

compiler/rustc_borrowck/src/def_use.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
1616

1717
PlaceContext::MutatingUse(MutatingUseContext::Store) |
1818

19-
// This is potentially both a def and a use...
20-
PlaceContext::MutatingUse(MutatingUseContext::LlvmAsmOutput) |
21-
2219
// We let Call define the result in both the success and
2320
// unwind cases. This is not really correct, however it
2421
// does not seem to be observable due to the way that we

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ use rustc_middle::mir::{BorrowKind, Mutability, Operand};
55
use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind};
66
use rustc_middle::mir::{Statement, StatementKind};
77
use rustc_middle::ty::TyCtxt;
8-
use std::iter;
98

109
use crate::{
1110
borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, path_utils::*, AccessDepth,
1211
Activation, ArtificialField, BorrowIndex, Deep, JustWrite, LocalMutationIsAllowed, MutateMode,
13-
Read, ReadKind, ReadOrWrite, Reservation, Shallow, Write, WriteAndRead, WriteKind,
12+
Read, ReadKind, ReadOrWrite, Reservation, Shallow, Write, WriteKind,
1413
};
1514

1615
pub(super) fn generate_invalidates<'tcx>(
@@ -67,30 +66,6 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
6766
StatementKind::SetDiscriminant { place, variant_index: _ } => {
6867
self.mutate_place(location, **place, Shallow(None), JustWrite);
6968
}
70-
StatementKind::LlvmInlineAsm(asm) => {
71-
for (o, output) in iter::zip(&asm.asm.outputs, &*asm.outputs) {
72-
if o.is_indirect {
73-
// FIXME(eddyb) indirect inline asm outputs should
74-
// be encoded through MIR place derefs instead.
75-
self.access_place(
76-
location,
77-
*output,
78-
(Deep, Read(ReadKind::Copy)),
79-
LocalMutationIsAllowed::No,
80-
);
81-
} else {
82-
self.mutate_place(
83-
location,
84-
*output,
85-
if o.is_rw { Deep } else { Shallow(None) },
86-
if o.is_rw { WriteAndRead } else { JustWrite },
87-
);
88-
}
89-
}
90-
for (_, input) in asm.inputs.iter() {
91-
self.consume_operand(location, input);
92-
}
93-
}
9469
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
9570
ref src,
9671
ref dst,

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use either::Either;
4040
use smallvec::SmallVec;
4141
use std::cell::RefCell;
4242
use std::collections::BTreeMap;
43-
use std::iter;
4443
use std::mem;
4544
use std::rc::Rc;
4645

@@ -55,7 +54,7 @@ use rustc_mir_dataflow::MoveDataParamEnv;
5554
use self::diagnostics::{AccessKind, RegionName};
5655
use self::location::LocationTable;
5756
use self::prefixes::PrefixSet;
58-
use self::MutateMode::{JustWrite, WriteAndRead};
57+
use self::MutateMode::JustWrite;
5958
use facts::AllFacts;
6059

6160
use self::path_utils::*;
@@ -653,39 +652,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
653652
StatementKind::SetDiscriminant { place, variant_index: _ } => {
654653
self.mutate_place(location, (**place, span), Shallow(None), JustWrite, flow_state);
655654
}
656-
StatementKind::LlvmInlineAsm(ref asm) => {
657-
for (o, output) in iter::zip(&asm.asm.outputs, &*asm.outputs) {
658-
if o.is_indirect {
659-
// FIXME(eddyb) indirect inline asm outputs should
660-
// be encoded through MIR place derefs instead.
661-
self.access_place(
662-
location,
663-
(*output, o.span),
664-
(Deep, Read(ReadKind::Copy)),
665-
LocalMutationIsAllowed::No,
666-
flow_state,
667-
);
668-
self.check_if_path_or_subpath_is_moved(
669-
location,
670-
InitializationRequiringAction::Use,
671-
(output.as_ref(), o.span),
672-
flow_state,
673-
);
674-
} else {
675-
self.mutate_place(
676-
location,
677-
(*output, o.span),
678-
if o.is_rw { Deep } else { Shallow(None) },
679-
if o.is_rw { WriteAndRead } else { JustWrite },
680-
flow_state,
681-
);
682-
}
683-
}
684-
for (_, input) in asm.inputs.iter() {
685-
self.consume_operand(location, (input, span), flow_state);
686-
}
687-
}
688-
689655
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
690656
..
691657
}) => {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14771477
StatementKind::FakeRead(..)
14781478
| StatementKind::StorageLive(..)
14791479
| StatementKind::StorageDead(..)
1480-
| StatementKind::LlvmInlineAsm { .. }
14811480
| StatementKind::Retag { .. }
14821481
| StatementKind::Coverage(..)
14831482
| StatementKind::Nop => {}

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ pub fn parse_asm_args<'a>(
5050
return Err(diag.struct_span_err(sp, "requires at least a template string argument"));
5151
}
5252

53-
// Detect use of the legacy llvm_asm! syntax (which used to be called asm!)
54-
if !is_global_asm && p.look_ahead(1, |t| *t == token::Colon || *t == token::ModSep) {
55-
let mut err =
56-
diag.struct_span_err(sp, "the legacy LLVM-style asm! syntax is no longer supported");
57-
err.note("consider migrating to the new asm! syntax specified in RFC 2873");
58-
err.note("alternatively, switch to llvm_asm! to keep your code working as it is");
59-
return Err(err);
60-
}
61-
6253
let first_template = p.parse_expr()?;
6354
let mut args = AsmArgs {
6455
templates: vec![first_template],

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ mod env;
3333
mod format;
3434
mod format_foreign;
3535
mod global_allocator;
36-
mod llvm_asm;
3736
mod log_syntax;
3837
mod panic;
3938
mod source_util;
@@ -78,7 +77,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
7877
include_str: source_util::expand_include_str,
7978
include: source_util::expand_include,
8079
line: source_util::expand_line,
81-
llvm_asm: llvm_asm::expand_llvm_asm,
8280
log_syntax: log_syntax::expand_log_syntax,
8381
module_path: source_util::expand_mod,
8482
option_env: env::expand_option_env,

0 commit comments

Comments
 (0)