OrcCompiler
OrcCompiler is the object used to convert Orc programs contained in an OrcProgram object into assembly code and object code.
The OrcCompileResult enum is used to indicate whether or not a compilation attempt was successful or not. The macros ORC_COMPILE_RESULT_IS_SUCCESSFUL and ORC_COMPILE_RESULT_IS_FATAL should be used instead of checking values directly.
When a program is compiled, the compiler calls the functions contained in various OrcRule structures. These functions generate assembly and object instructions by calling ORC_ASM_CODE or functions that use ORC_ASM_CODE internally.
Functions
orc_compiler_append_code
void
orc_compiler_append_code (OrcCompiler* p,
const char * fmt)
Generates a string using sprintf on the given format and arguments, and appends that string to the generated assembly code for the compiler.
This function is used by the ORC_ASM_CODE macro.
This function is useful in a function implementing an OrcRule or implementing a target.
Parameters:
p
–
an OrcCompiler object
fmt
–
a printf-style format string
orc_compiler_error
void
orc_compiler_error (OrcCompiler* compiler,
const char * fmt)
Parameters:
compiler
–
fmt
–
orc_compiler_get_constant
int
orc_compiler_get_constant (OrcCompiler* compiler,
int size,
int value)
Loads a constant into a register
compiler: The compiler that loads the constant size: The size of the value. One, two or four bytes value: The constant value returns: The register with the constant stored or ORC_REG_INVALID
Gets a constant as a registry splatting the value into the whole register. The size defines what will be splatted into registry from value.
In case a constant can not be generated, due to missing temporary registers, or too many compiler constants ORC_REG_INVALID will be returned. Failing will trigger an ORC_COMPILER_ERROR
This function is deprecated and orc_compiler_get_constant_full should be used.
Parameters:
compiler
–
size
–
value
–
orc_compiler_get_constant_long
int
orc_compiler_get_constant_long (OrcCompiler* compiler,
orc_uint32 a,
orc_uint32 b,
orc_uint32 c,
orc_uint32 d)
Loads a 128-bit constant into a register
compiler: The compiler that loads the constant a: The first 32-bits of the value to load as a constant b: The second 32-bits of the value to load as a constant c: The third 32-bits of the value to load as a constant d: The fourth 32-bits of the value to load as a constant returns: The register with the constant stored or ORC_REG_INVALID
Gets a constant as a registry filling 128-bits only of the whole register.
In case a constant can not be generated, due to missing temporary registers, or too many compiler constants ORC_REG_INVALID will be returned. Failing will trigger an ORC_COMPILER_ERROR
This function is deprecated and orc_compiler_get_constant_full should be used. Note that a, b, c, and d are stored in little-endian form in a 128-bits little-endian memory area, therefore, they are stored like [@a, b, c, d] being a at memory address 0, b at memory address 32, c at memory address 64, and d at memory address 96
Parameters:
compiler
–
a
–
b
–
c
–
d
–
orc_compiler_get_constant_reg
int orc_compiler_get_constant_reg (OrcCompiler* compiler)
Parameters:
compiler
–
orc_compiler_get_temp_constant
int
orc_compiler_get_temp_constant (OrcCompiler* compiler,
int size,
int value)
Loads a temporary constant into a register
compiler: The compiler that loads the temporary constant size: The size of the value. One, two or four bytes value: The constant value returns: The register with the constant stored or ORC_REG_INVALID
Gets a constant as a registry splatting the value into the whole register. The size defines what will be splatted into registry from value.
Temporary constants are generated inplace on every call This is different from general constants that will be generate code at the beginning of the generated code.
This function is deprecated and orc_compiler_get_temp_constant_full should be used.
Parameters:
compiler
–
size
–
value
–
orc_compiler_get_temp_reg
int orc_compiler_get_temp_reg (OrcCompiler* compiler)
Parameters:
compiler
–
orc_compiler_label_new
int orc_compiler_label_new (OrcCompiler* compiler)
Parameters:
compiler
–
orc_compiler_try_get_constant_long
int
orc_compiler_try_get_constant_long (OrcCompiler* compiler,
orc_uint32 a,
orc_uint32 b,
orc_uint32 c,
orc_uint32 d)
Tries to load a 128-bit constant into a register
compiler: The compiler that loads the constant a: The first 32-bits of the value to load as a constant b: The second 32-bits of the value to load as a constant c: The third 32-bits of the value to load as a constant d: The fourth 32-bits of the value to load as a constant returns: The register with the constant stored or ORC_REG_INVALID
Similar to orc_compiler_get_constant_long but will not trigger an ORC_COMPILER_ERROR if failing. This is useful for rules that have different altrnatives of implementation depending if the constant can be loaded or not.
This function is deprecated and orc_compiler_try_get_constant_full should be used. Note that a, b, c, and d are stored in little-endian form in a 128-bits little-endian memory area, therefore, they are stored like [@a, b, c, d] being a at memory address 0, b at memory address 32, c at memory address 64, and d at memory address 96
Parameters:
compiler
–
a
–
b
–
c
–
d
–
The results of the search are