[LLVMdev] C int type for 48bits cpu

Stephen Checkoway s at pahtak.org
Thu Sep 5 00:59:45 PDT 2013


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







More information about the llvm-dev mailing list