I sense some confusion here. A custom instruction is defined with the following format in Nios assembly:
custom 0, r6, r7, r8
Everything else you see in C code such as macros somehow ultimately emit this instruction when passed through the compiler. There are multiple types of custom instructions. If we take the simplest form which is a combinational CI with just 1 input, it would be exposed to the C programmer as something like this:
__builtin_custom_<CI_idx><arg1_type><arg2_type> (int n, arg1_type dataa, arg2_type datab)
To avoid programmers from calling a complicated function like a __builtin_custom_xxx, the compiler just generates a macro in system.h which wraps this and avoids the programmer from having to supply the number "n" above (the index of the CI as defined in platform designer).
The bitswap instrution you are trying to use is an existing CI that exists in qsys and which you can decide to add to the nios processor if you wish. This instruction should just swap 31..0 to 0..31. I can't say much about how this particular intel-provided CI is implemented as I have not used it. What I know for sure though is that you cannot change its functionality as somewhere there is a VHDL/Verilog file that describes it's design, and this file is not provided by you.
If you want to see how to really create a CI of your own that does this bit swapping, you should write it yourself. To do this, just write a simple VHDL file with the expected interface of the CI as defined in the Custom Instruction User Guide. For example, a simple combinatorial CI that just uses 1 input could look like this:
![](https://moodlearchive.epfl.ch/2019-2020/pluginfile.php/1778849/mod_forum/post/67677/Screenshot_20200423_191648.png)
You can then go to Qsys and create a new component (just as you created slaves in the previous labs). You provide this VHDL file and tell it to analyze it, then you go to the "Signals and Interfaces" tab and you define what the interface looks like to Qsys. In this case we are not defining a slave, but a "Custom Instruction Slave" in the available interface categories. You can then see signal types such as "dataa", "datab", ... in there which you assign to the corresponding ports of the VHDL design above.
Once you do all this and wire this CI to the CPU, it will be assigned a number and a macro will automatically be generated to wrap it's invocation in system.h. You therefore should not need to define the macro yourself, as I understand you are trying to do.