I’m working on a custom language front-end for GCC and need to embed inline assembly commands for different architectures. For instance:
#if CPU_ARM
asm_cmd(loadReg, storeVal);
#endif
How do I achieve this?
I’m working on a custom language front-end for GCC and need to embed inline assembly commands for different architectures. For instance:
#if CPU_ARM
asm_cmd(loadReg, storeVal);
#endif
How do I achieve this?
hey finn, have you tried using gcc’s attribute((target)) to separate arch-specific funcs instead of inline conditions? i’m tinkering with similar issues and it seems a neat workaround. whatchu think? any hiccups so far?
hey finn, try using asm macros with #if conditions. check out gcc’s inline asm docs, it might help. seems to work for me when combining those nicely.
In my work with inline assembly in GCC, I found that isolating architecture-specific code into distinct compilation units provides a cleaner approach. For example, creating separate source files and enabling them via build scripts or Makefile conditions reduces clutter in your main code. This method allows each unit to focus on a single architecture, easing maintenance and debugging. It also helps in keeping the front-end logic cleaner while utilizing the appropriate inline assembly syntax tailored for each architecture during compilation.