1
1
/* ******************************************************************\
2
2
3
- Module: Remove 'asm' statements by compiling into suitable standard
4
- code
3
+ Module: Remove 'asm' statements by compiling them into suitable
4
+ standard goto program instructions
5
5
6
6
Author: Daniel Kroening
7
7
@@ -10,7 +10,8 @@ Date: December 2014
10
10
\*******************************************************************/
11
11
12
12
// / \file
13
- // / Remove 'asm' statements by compiling into suitable standard code
13
+ // / Remove 'asm' statements by compiling them into suitable standard goto
14
+ // / program instructions
14
15
15
16
#include " remove_asm.h"
16
17
@@ -61,6 +62,13 @@ class remove_asmt
61
62
goto_programt &dest);
62
63
};
63
64
65
+ // / Adds a call to a library function that implements the given gcc-style inline
66
+ // / assembly statement
67
+ // /
68
+ // / \param function_base_name: Name of the function to call
69
+ // / \param code: gcc-style inline assembly statement to translate to function
70
+ // / call
71
+ // / \param dest: Goto program to append the function call to
64
72
void remove_asmt::gcc_asm_function_call (
65
73
const irep_idt &function_base_name,
66
74
const code_asmt &code,
@@ -128,6 +136,13 @@ void remove_asmt::gcc_asm_function_call(
128
136
}
129
137
}
130
138
139
+ // / Adds a call to a library function that implements the given msc-style inline
140
+ // / assembly statement
141
+ // /
142
+ // / \param function_base_name: Name of the function to call
143
+ // / \param code: msc-style inline assembly statement to translate to function
144
+ // / call
145
+ // / \param dest: Goto program to append the function call to
131
146
void remove_asmt::msc_asm_function_call (
132
147
const irep_idt &function_base_name,
133
148
const code_asmt &code,
@@ -171,7 +186,12 @@ void remove_asmt::msc_asm_function_call(
171
186
}
172
187
}
173
188
174
- // / removes assembler
189
+ // / Translates the given inline assembly code (which must be in either gcc or
190
+ // / msc style) to non-assembly goto program instructions
191
+ // /
192
+ // / \param instruction: The goto program instruction containing the inline
193
+ // / assembly statements
194
+ // / \param dest: The goto program to append the new instructions to
175
195
void remove_asmt::process_instruction (
176
196
goto_programt::instructiont &instruction,
177
197
goto_programt &dest)
@@ -188,7 +208,11 @@ void remove_asmt::process_instruction(
188
208
DATA_INVARIANT (false , " unexpected assembler flavor" );
189
209
}
190
210
191
- // / removes gcc assembler
211
+ // / Translates the given inline assembly code (in gcc style) to non-assembly
212
+ // / goto program instructions
213
+ // /
214
+ // / \param code: The inline assembly code statement to translate
215
+ // / \param dest: The goto program to append the new instructions to
192
216
void remove_asmt::process_instruction_gcc (
193
217
const code_asmt &code,
194
218
goto_programt &dest)
@@ -349,7 +373,11 @@ void remove_asmt::process_instruction_gcc(
349
373
dest.destructive_append (tmp_dest);
350
374
}
351
375
352
- // / removes msc assembler
376
+ // / Translates the given inline assembly code (in msc style) to non-assembly
377
+ // / goto program instructions
378
+ // /
379
+ // / \param code: The inline assembly code statement to translate
380
+ // / \param dest: The goto program to append the new instructions to
353
381
void remove_asmt::process_instruction_msc (
354
382
const code_asmt &code,
355
383
goto_programt &dest)
@@ -449,7 +477,10 @@ void remove_asmt::process_instruction_msc(
449
477
dest.destructive_append (tmp_dest);
450
478
}
451
479
452
- // / removes assembler
480
+ // / Replaces inline assembly instructions in the goto function by non-assembly
481
+ // / goto program instructions
482
+ // /
483
+ // / \param goto_function: The goto function
453
484
void remove_asmt::process_function (
454
485
goto_functionst::goto_functiont &goto_function)
455
486
{
@@ -478,14 +509,23 @@ void remove_asmt::process_function(
478
509
remove_skip (goto_function.body );
479
510
}
480
511
481
- // / removes assembler
512
+ // / \copybrief remove_asm(goto_modelt &)
513
+ // /
514
+ // / \param goto_functions: The goto functions
515
+ // / \param symbol_table: The symbol table
482
516
void remove_asm (goto_functionst &goto_functions, symbol_tablet &symbol_table)
483
517
{
484
518
remove_asmt rem (symbol_table, goto_functions);
485
519
rem ();
486
520
}
487
521
488
- // / removes assembler
522
+ // / Replaces inline assembly instructions in the goto program (i.e.,
523
+ // / instructions of kind `OTHER` with a `code` member of type `code_asmt`) with
524
+ // / an appropriate (sequence of) non-assembly goto program instruction(s). At
525
+ // / present only a small number of x86 and Power instructions are supported.
526
+ // / Unrecognised assembly instructions are ignored.
527
+ // /
528
+ // / \param goto_model: The goto model
489
529
void remove_asm (goto_modelt &goto_model)
490
530
{
491
531
remove_asm (goto_model.goto_functions , goto_model.symbol_table );
0 commit comments