Clang datalayout for pure 64 bit cpu

Hi all,

i am writing a compiler for a 64bit cpu, which only operates on 64bit. In order to clang and llc to take this into account I have set the datalayout to:

// resetDataLayout(“E-m:e-p:64:64-S64-i1:64:64-i8:64:64-i16:64:64-”
// “i32:64:64-i64:64:64-f16:64:64-f32:64:64-f64:64:64-a:0:64-n64”);

    resetDataLayout("E-m:e-p:64:64-S64-i64:64:64-f64:64:64-a:0:64-n64");

I have tried different combinations, but char, short and float data types are always set to i8, i16 and float.

Is there any other way to tell clang, that all data types are 64bit wide?

regards
Thomas

Hi Thomas!

I understand your question in the way that you want the C data types bool, char, short, … to be all 64 bit wide. This is not controlled by the data layout. The data layout defined in clang must match the data layout used by the backend. See last paragraph in LLVM Language Reference Manual — LLVM 13 documentation.

Just looking at the clang source, my suggestion is to have a look at clang/include/clang/Basic/TargetInfo.h. There is a couple of methods getXXXWidth(), which you may want to override for your target.

Regards,
Kai

1 Like

Dear Kai,

thanks for your reply. I am working with version 12.0.0. I have set the data layout string in both, clang and llvm. I also saw that char and short width are hard coded in TargetInfo.h. I have changed this too and made it configurable.

Unfortunately clang and llvm are using 8 bit for stack calculations. I have found a document from embecosm talking about ‘Non 8 bit byte support…’(2017) and a longer discussion from am ericsson person about ’ Non-8-bit addressable units’ (⚙ D61725 Non-8-bit addressable units showcase).

It looks like I have to take the same route.

Does some one have done this already and has patch set available?

Regards
Thomas