11#include " rust-compile-asm.h"
22#include " rust-compile-expr.h"
33#include " rust-system.h"
4+ #include " rust-ggc.h"
45
56namespace Rust {
67namespace Compile {
78
8- static tree
9- chain_asm_operand (tree head , const char *constraint, tree value)
9+ static void
10+ chain_asm_operand (GGC ::ChainList &ls , const char *constraint, tree value)
1011{
1112 auto name = build_string (strlen (constraint) + 1 , constraint);
12- return chainon (head,
13- build_tree_list (build_tree_list (NULL_TREE , name), value));
13+ ls.push_back (build_tree_list (build_tree_list (NULL_TREE , name), value));
1414}
1515
1616CompileAsm::CompileAsm (Context *ctx) : HIRCompileBase (ctx) {}
@@ -107,7 +107,7 @@ CompileAsm::asm_construct_outputs (HIR::InlineAsm &expr)
107107{
108108 // TODO: Do i need to do this?
109109
110- tree head = NULL_TREE ;
110+ GGC ::ChainList ls ;
111111 for (auto &operand : expr.get_operands ())
112112 {
113113 tl::optional<std::reference_wrapper<HIR ::Expr>> out_expr
@@ -118,9 +118,9 @@ CompileAsm::asm_construct_outputs (HIR::InlineAsm &expr)
118118 tree out_tree = CompileExpr::Compile (*out_expr, this ->ctx );
119119 // expects a tree list
120120 // TODO: This assumes that the output is a register
121- head = chain_asm_operand (head , " =r" , out_tree);
121+ chain_asm_operand (ls , " =r" , out_tree);
122122 }
123- return head ;
123+ return ls. get_head () ;
124124}
125125
126126tl::optional<std::reference_wrapper<HIR ::Expr>>
147147CompileAsm::asm_construct_inputs (HIR ::InlineAsm &expr)
148148{
149149 // TODO: Do i need to do this?
150- tree head = NULL_TREE ;
150+
151+ GGC ::ChainList ls;
151152 for (auto &operand : expr.get_operands ())
152153 {
153154 tl::optional<std::reference_wrapper<HIR ::Expr>> in_expr
@@ -158,9 +159,9 @@ CompileAsm::asm_construct_inputs (HIR::InlineAsm &expr)
158159 tree in_tree = CompileExpr::Compile (*in_expr, this ->ctx );
159160 // expects a tree list
160161 // TODO: This assumes that the input is a register
161- head = chain_asm_operand (head , " r" , in_tree);
162+ chain_asm_operand (ls , " r" , in_tree);
162163 }
163- return head ;
164+ return ls. get_head () ;
164165}
165166
166167tree
@@ -182,29 +183,28 @@ CompileLlvmAsm::CompileLlvmAsm (Context *ctx) : HIRCompileBase (ctx) {}
182183tree
183184CompileLlvmAsm::construct_operands (std::vector<HIR ::LlvmOperand> operands)
184185{
185- tree head = NULL_TREE ;
186+ GGC ::ChainList ls ;
186187 for (auto &operand : operands)
187188 {
188189 tree t = CompileExpr::Compile (*operand.expr , this ->ctx );
189190 auto name = build_string (operand.constraint .size () + 1 ,
190191 operand.constraint .c_str ());
191- head = chainon (head,
192- build_tree_list (build_tree_list (NULL_TREE , name), t));
192+ ls.push_back (build_tree_list (build_tree_list (NULL_TREE , name), t));
193193 }
194- return head ;
194+ return ls. get_head () ;
195195}
196196
197197tree
198198CompileLlvmAsm::construct_clobbers (std::vector<AST ::TupleClobber> clobbers)
199199{
200- tree head = NULL_TREE ;
200+ GGC ::ChainList ls ;
201201 for (auto &clobber : clobbers)
202202 {
203203 auto name
204204 = build_string (clobber.symbol .size () + 1 , clobber.symbol .c_str ());
205- head = chainon (head, build_tree_list (NULL_TREE , name));
205+ ls. push_back ( build_tree_list (NULL_TREE , name));
206206 }
207- return head ;
207+ return ls. get_head () ;
208208}
209209
210210tree
0 commit comments