Quiz time
Now that you have finished reading this chapter, try answering the following questions to test your knowledge:
- Are intrinsics the only option to experiment with target-specific constructs?
No, you can start with inline assembly. Inline assembly does not require any change to the compiler, whereas intrinsics do. However, inline assembly puts additional constraints on the optimizers and these constraints may degrade the quality of the generated code.
See the The pros and cons of intrinsics section for more details.
- How can you quickly check whether Clang knows about your target?
Clang can print all the targets it has been built for by using the --print-targets
option. You can then check whether the target is hooked up by printing some IR with Clang, using -target <yourTarget> -S -emit-llvm
.
See the Plumbing your Target through Clang section.
- How can you inject a pass into the default optimization pipeline? ...