Forum Discussion
Altera_Forum
Honored Contributor
12 years agoYou'd need to rebuild gcc with extra instruction definitions in order to get it to use your custom instructions.
Below is an example of the asm wrapper for a custom instruction. I'm not sure how to get a double value into two registers, try using a local variable that is a union of a double and two ints./* There are 'int __builtin_custom_inii(int op, int a, int b)'
* (and similar) wrappers for custom instructions defined by gcc itself.
* But none for the 'c' variants that do not use the main register file.
* The one below is useful when the 'b' field is used as a sub-opcode.*/
__attribute__((always_inline))
static __inline__ uint32_t
custom_inic(const uint32_t op, uint32_t a, const uint32_t b)
{
uint32_t result;
__asm__ ( "custom\t%1, %0, %2, c%3"
: "=r" (result) : "n" (op), "r" (a), "n" (b));
return result;
}