[cfe-dev] how to change the pointer size to 64 bits in 32bit target

Lori Yao Yu via cfe-dev cfe-dev at lists.llvm.org
Sun Apr 19 22:32:27 PDT 2020


Hi all developers,
I'm currently working on a RISCV target with two address mode, 32 bit and 64 bit.  And all the registers are 32bits.
    The first thing I dose was changing the data layout of this target. So  I change the data layout string to "e-m:e-p:64:64-p1:64:32-i64:64-n32-S128" in clang/lib/Basic/Targets/RISCV.h and llvm/lib/TargetRISCV/RISCVTargteMachine.cpp.

    But I found that not work as expected, following is my test code:

    C language:

    int func() {
   return sizeof(int*);
}


    the IR code is :

    target datalayout = "e-m:e-p:64:64-p1:64:32-i64:64-n32-S128"
    target triple = "riscv32-unkown-unkown-elf"
     define dso_ocal i32 @func() local_unnamed_addr #0 {
entry:
   ret i32 4
}

     I see that the size of int* is 4 bytes, it is 32bits, not 64 bits as expected.

      Can you tell me if I am wrong in somewhere, or the way to change the pointer size correctly.

      Thank you all for your time and any help you can provide.
Lori
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200420/60b62ddf/attachment.html>


More information about the cfe-dev mailing list