So far, I still have two questions. The first is: I am not clear the LLVM / CLANG operating mechanism .can you send me some relevant information? The second is: I am using the compiler environment is LLVM and CLANG. The official description of the CLANG is equivalent to the front, like lexical analysis and parsing. LLVM is equivalent to the back-end, mainly intermediate code generation and optimization. I now want to add a recognition to new type , should be in the LLVM or the CLANG to add the relevant code?
So far, I still have two questions. The first is: I am not clear the LLVM /
CLANG operating mechanism .can you send me some relevant information?
I don't think this is a coherent question. If you're asking how LLVM
and Clang work you're going to have to be a lot more directed. We
could write a hundred articles and we'd miss important details.
In the very broadest outline Clang parses C, C++ and related languages
and produces LLVM IR (look for files ending in .ll in the LLVM
sources). The bulk of LLVM itself is dedicated to optimizing this IR
and converting it into CPU-specific assembly and object files.
The
official description of the CLANG is equivalent to the front, like lexical
analysis and parsing. LLVM is equivalent to the back-end, mainly
intermediate code generation and optimization. I now want to add a
recognition to new type , should be in the LLVM or the CLANG to add the
relevant code?
If the new type is for C or C++ the chances are you only need to
modify Clang. You can usually decide on a roughly equivalent LLVM type
(maybe a struct or something) and emit all the necessary IR to handle
it from Clang.
Certain really odd ideas might need LLVM changes too: the most recent
one I know of is ARM's proposal for vectors that have a size that's
only known at runtime.
Hi, my apologies bringing up this old thread up again. Could you kindly elaborate on this part, by adding a struct, do you mean one adds another type by looking at how struct type is defined in clang? If so could you give me an example of which files one should start with?
To give you more context regarding my problem we are working on adding a custom register to RISCV and we need a new type to be added which only stores or loads from that particular register. Right now I am still playing around, (making changes and seeing output whether it actually makes sense or not) so I added a new derived type for that register in LLVM using the extending LLVM tutorial https://llvm.org/docs/ExtendingLLVM.html for adding a new derived type. However, I am having issues making clang recognize my added type.
Am I correct in assuming that just making changes to llvm as mentioned in the tutorial won’t work if I am trying to compile from C to object code. Following the tutorial, only IR to object code would compile and I would need to make changes to clang too? I am a beginner so my apologies if I am completely off the mark.