[LLVMdev] C int type for 48bits cpu

gamma_chen gamma_chen at yahoo.com.tw
Thu Sep 5 02:12:45 PDT 2013


Stephen,
Thank you. The llvm IR accept the i48 but it will fail if I use i48 as data type in *.td file. Do you know how to add i48 type in *.td, or it is not allowed.
The other question is "Is it possible to make clang compiler generate i48 for "C int type varialbe?". If you don't know the answer of this clang question I will post it on clang development list.

Best regards

Jonathan



________________________________
 寄件者: Stephen Checkoway <s at pahtak.org>
收件者: gamma_chen <gamma_chen at yahoo.com.tw> 
副本: "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu>; Vijay Daultani <vijay.daultani at gmail.com> 
寄件日期: 2013/9/5 (週四) 3:59 PM
主旨: Re: [LLVMdev] C int type for 48bits cpu
 


On Sep 5, 2013, at 3:37 AM, gamma_chen <gamma_chen at yahoo.com.tw> wrote:

> LLVM only support primitive type i32 and i64, no i48. The clang translate "C int type" to i32 too. My question is if a cpu is 48 bits register size, how to write the backend for 48 bits register architecture. Can someone help me with this problem?


I'm not LLVM expert, but I'm pretty sure your initial sentence is false. For example:

steve$ cat a.ll
; ModuleID = 'a.c'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.8.0"

define i48 @foo() nounwind uwtable ssp {
  ret i48 3
}
steve$ clang -S a.ll
steve$ cat a.s
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _foo
    .align    4, 0x90
_foo:                                   ## @foo
    .cfi_startproc
## BB#0:
    pushq    %rbp
Ltmp2:
    .cfi_def_cfa_offset 16
Ltmp3:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
Ltmp4:
    .cfi_def_cfa_register %rbp
    movl    $3, %eax
    popq    %rbp
    ret
    .cfi_endproc


.subsections_via_symbols

As you can see, i48 was a perfectly valid LLVM type.

Without having written a backend, I'd imagine you specify what types are legal and then either generic code or target-dependent code is going to legalize the type. In my example, I imagine the i48 was legalized to an i64 which is legal for my target architecture.

-- 
Stephen Checkoway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130905/0de5e8a2/attachment.html>


More information about the llvm-dev mailing list