@@ -8,8 +8,6 @@ use std::sync::Arc;
8
8
9
9
use rustc_ast:: { InlineAsmOptions , InlineAsmTemplatePiece } ;
10
10
use rustc_codegen_ssa:: traits:: { AsmCodegenMethods , GlobalAsmOperandRef } ;
11
- use rustc_hir:: { InlineAsmOperand , ItemId } ;
12
- use rustc_middle:: mir:: interpret:: ErrorHandled ;
13
11
use rustc_middle:: ty:: TyCtxt ;
14
12
use rustc_middle:: ty:: layout:: {
15
13
FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasTyCtxt , HasTypingEnv , LayoutError , LayoutOfHelpers ,
@@ -84,72 +82,6 @@ impl<'tcx> HasTypingEnv<'tcx> for GlobalAsmContext<'_, 'tcx> {
84
82
}
85
83
}
86
84
87
- pub ( crate ) fn codegen_global_asm_item ( tcx : TyCtxt < ' _ > , global_asm : & mut String , item_id : ItemId ) {
88
- let item = tcx. hir_item ( item_id) ;
89
- let rustc_hir:: ItemKind :: GlobalAsm { asm, .. } = item. kind else {
90
- bug ! ( "Expected GlobalAsm found {:?}" , item) ;
91
- } ;
92
-
93
- // Adapted from rustc_codegen_ssa::mono_items::MonoItem::define
94
- let operands: Vec < _ > = asm
95
- . operands
96
- . iter ( )
97
- . map ( |( op, op_sp) | match * op {
98
- InlineAsmOperand :: Const { ref anon_const } => {
99
- match tcx. const_eval_poly ( anon_const. def_id . to_def_id ( ) ) {
100
- Ok ( const_value) => {
101
- let ty = tcx. typeck_body ( anon_const. body ) . node_type ( anon_const. hir_id ) ;
102
- let string = rustc_codegen_ssa:: common:: asm_const_to_str (
103
- tcx,
104
- * op_sp,
105
- const_value,
106
- FullyMonomorphizedLayoutCx ( tcx) . layout_of ( ty) ,
107
- ) ;
108
- GlobalAsmOperandRef :: Const { string }
109
- }
110
- Err ( ErrorHandled :: Reported { .. } ) => {
111
- // An error has already been reported and
112
- // compilation is guaranteed to fail if execution
113
- // hits this path. So an empty string instead of
114
- // a stringified constant value will suffice.
115
- GlobalAsmOperandRef :: Const { string : String :: new ( ) }
116
- }
117
- Err ( ErrorHandled :: TooGeneric ( _) ) => {
118
- span_bug ! ( * op_sp, "asm const cannot be resolved; too generic" )
119
- }
120
- }
121
- }
122
- InlineAsmOperand :: SymFn { expr } => {
123
- if cfg ! ( not( feature = "inline_asm_sym" ) ) {
124
- tcx. dcx ( ) . span_err (
125
- item. span ,
126
- "asm! and global_asm! sym operands are not yet supported" ,
127
- ) ;
128
- }
129
-
130
- let ty = tcx. typeck ( item_id. owner_id ) . expr_ty ( expr) ;
131
- let instance = match ty. kind ( ) {
132
- & ty:: FnDef ( def_id, args) => Instance :: new ( def_id, args) ,
133
- _ => span_bug ! ( * op_sp, "asm sym is not a function" ) ,
134
- } ;
135
- GlobalAsmOperandRef :: SymFn { instance }
136
- }
137
- InlineAsmOperand :: SymStatic { path : _, def_id } => {
138
- GlobalAsmOperandRef :: SymStatic { def_id }
139
- }
140
- InlineAsmOperand :: In { .. }
141
- | InlineAsmOperand :: Out { .. }
142
- | InlineAsmOperand :: InOut { .. }
143
- | InlineAsmOperand :: SplitInOut { .. }
144
- | InlineAsmOperand :: Label { .. } => {
145
- span_bug ! ( * op_sp, "invalid operand type for global_asm!" )
146
- }
147
- } )
148
- . collect ( ) ;
149
-
150
- codegen_global_asm_inner ( tcx, global_asm, asm. template , & operands, asm. options ) ;
151
- }
152
-
153
85
fn codegen_global_asm_inner < ' tcx > (
154
86
tcx : TyCtxt < ' tcx > ,
155
87
global_asm : & mut String ,
0 commit comments