zezba9000
zezba9000

Reputation: 3383

Does LLVM IR support (byte = 16bit)?

Wondering if LLVM supports bytes with a size of 16bit etc (not just 8bit)? Is it possible to make a language that targets LLVM and supports this concept for custom 16bit FPGA-CPUs ?

From my understanding Clang doesn't support this while GCC can BUT does LLVM IR?

Upvotes: 0

Views: 727

Answers (1)

DTharun
DTharun

Reputation: 796

In LLVM there is no specific concept of bytes, int, etc. All it supports is integers with arbitrary bit width (iN).

1 <= N <= (2^23)-1

https://llvm.org/docs/LangRef.html#integer-type

Suppose, in some language a byte = 16 bits, the language front-end should make sure it generates i16 instead of i8. LLVM IR is designed to accommodate many different languages, that is the reason for this arbitrary integer bit widths.

Is it possible to make a language that targets LLVM and supports this concept for custom 16bit FPGA-CPUs ?

Yes, I understood the term "16-bit FPGA-CPU" as a 16-bit soft processor. LLVM does natively support processors with various bit widths. To my understanding, it does not matter if it is a soft processor or not.

In LLVM IR at the top, we find something called data layout. The one below is X86_64 data layout. n8:16:32:64 indicates the processor has native support for processing 64, 32, 16 and 8 bits, this means it is a 64-bit processor with backward compatibility.

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

Information about the rest of the field can found here. https://llvm.org/docs/LangRef.html#langref-datalayout

Upvotes: 1

Related Questions