[LLVMdev] Two questions about creating a new target

Lorenzo De Carli lorenzo at cs.wisc.edu
Tue Nov 9 18:04:06 PST 2010


Hi list,

I am in the process of creating a new target in LLVM/Clang for a
custom 16-bit machine. My initial goal is to configure Clang so that
when LLVM bytecode (or assembly) is generated, the integer size is 16
bits.

After defining an appropriate TargetInfo subclass (where integer size
is set to 16) the generated LLVM assembly looks almost correct,
however one of the parameters for getelementptr still gets passed as a
32-bit integer:

%1 = load i16* getelementptr inbounds ([5 x i16]*
@myfunc.auto.myvector, i32 0, i16 0)

This fact disturbs me slightly, because it means that Clang somehow
still "thinks" that the target has the notion of 32-bit variables
(which is incorrect). Could anyone give me a hint on how to fix it?

Another thing I have noticed... this is more a curiosity about Clang
internals :-) When I generate code using x86 as target, variables are
allocated with "alloca", but when I use my target they are simply
declared as auto-variables. Is there any way to get the same
allocation that is used for x86?

Thanks,
Lorenzo



More information about the llvm-dev mailing list