[llvm-commits] [llvm-gcc-4.2] r83226 - in /llvm-gcc-4.2/trunk/gcc/config/arm: neon-gen.ml neon.ml
Bob Wilson
bob.wilson at apple.com
Thu Oct 1 17:22:01 PDT 2009
Author: bwilson
Date: Thu Oct 1 19:22:01 2009
New Revision: 83226
URL: http://llvm.org/viewvc/llvm-project?rev=83226&view=rev
Log:
Change <arm_neon.h> to use standard types (from stdint.h) for NEON vector
element types. Add wrapper structs around vector types (using the
"Internal structure names" specified in Section A.2 of the ARM AAPCS
document). Revert some previous changes to remove casts, since I think
they are actually necessary to avoid some warnings. Revert almost all
llvm-specific changes to neon.ml -- they are not needed anymore.
Modified:
llvm-gcc-4.2/trunk/gcc/config/arm/neon-gen.ml
llvm-gcc-4.2/trunk/gcc/config/arm/neon.ml
Modified: llvm-gcc-4.2/trunk/gcc/config/arm/neon-gen.ml
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/neon-gen.ml?rev=83226&r1=83225&r2=83226&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/arm/neon-gen.ml (original)
+++ llvm-gcc-4.2/trunk/gcc/config/arm/neon-gen.ml Thu Oct 1 19:22:01 2009
@@ -124,12 +124,6 @@
let return_by_ptr features = List.mem ReturnPtr features
-let union_string num elts base =
- let itype = inttype_for_array num elts in
- let iname = string_of_inttype itype
- and sname = string_of_vectype (T_arrayof (num, elts)) in
- Printf.sprintf "union { %s __i; %s __o; } %s" sname iname base
-
let rec signed_ctype = function
T_uint8x8 | T_poly8x8 -> T_int8x8
| T_uint8x16 | T_poly8x16 -> T_int8x16
@@ -139,27 +133,45 @@
| T_uint32x4 -> T_int32x4
| T_uint64x1 -> T_int64x1
| T_uint64x2 -> T_int64x2
- (* Cast to types defined by mode in arm.c, not random types pulled in from
- the <stdint.h> header in use. This fixes incompatible pointer errors when
- compiling with C++. *)
- | T_uint8 | T_int8 -> T_intQI
- | T_uint16 | T_int16 -> T_intHI
- | T_uint32 | T_int32 -> T_intSI
- | T_uint64 | T_int64 -> T_intDI
- | T_poly8 -> T_intQI
- | T_poly16 -> T_intHI
+ (* LLVM LOCAL begin use standard type names *)
+ | T_uint8 -> T_int8
+ | T_uint16 -> T_int16
+ | T_uint32 -> T_int32
+ | T_uint64 -> T_int64
+ | T_poly8 -> T_int8
+ | T_poly16 -> T_int16
+ (* LLVM LOCAL end use standard type names *)
| T_arrayof (n, elt) -> T_arrayof (n, signed_ctype elt)
| T_ptrto elt -> T_ptrto (signed_ctype elt)
| T_const elt -> T_const (signed_ctype elt)
| x -> x
-let add_cast ctype cval =
+(* LLVM LOCAL begin union_string.
+ Array types are handled as structs in llvm-gcc, not as wide integers, and
+ single vector types have wrapper structs. Unions are used here to convert
+ back and forth between these different representations. The union_string
+ function has been updated accordingly, and it is moved below signed_ctype
+ so it can use that function. *)
+let union_string num elts base =
+ let itype = match num with
+ 1 -> elts
+ | _ -> T_arrayof (num, elts) in
+ let iname = string_of_vectype (signed_ctype itype)
+ and sname = string_of_vectype itype in
+ Printf.sprintf "union { %s __i; __neon_%s __o; } %s" sname iname base
+(* LLVM LOCAL end union_string. *)
+
+(* LLVM LOCAL begin add_cast_with_prefix. *)
+let add_cast_with_prefix ctype cval stype_prefix =
let stype = signed_ctype ctype in
if ctype <> stype then
- Printf.sprintf "(%s) %s" (string_of_vectype stype) cval
+ Printf.sprintf "(%s%s) %s" stype_prefix (string_of_vectype stype) cval
else
cval
+let add_cast ctype cval = add_cast_with_prefix ctype cval ""
+(* LLVM LOCAL end add_cast_with_prefix. *)
+
let cast_for_return to_ty = "(" ^ (string_of_vectype to_ty) ^ ")"
(* Return a tuple of a list of declarations to go at the start of the function,
@@ -178,6 +190,21 @@
else
let uname = union_string num vec "__rv" in
[uname], ["__rv.__o = " ^ thing; "__rv.__i"]
+ (* LLVM LOCAL begin Convert vector result to wrapper struct. *)
+ | T_int8x8 | T_int8x16
+ | T_int16x4 | T_int16x8
+ | T_int32x2 | T_int32x4
+ | T_int64x1 | T_int64x2
+ | T_uint8x8 | T_uint8x16
+ | T_uint16x4 | T_uint16x8
+ | T_uint32x2 | T_uint32x4
+ | T_uint64x1 | T_uint64x2
+ | T_float32x2 | T_float32x4
+ | T_poly8x8 | T_poly8x16
+ | T_poly16x4 | T_poly16x8 ->
+ let uname = union_string 1 ret "__rv" in
+ [uname], ["__rv.__o = " ^ thing; "__rv.__i"]
+ (* LLVM LOCAL end Convert vector result to wrapper struct. *)
| T_void -> [], [thing]
| _ ->
[], [(cast_for_return ret) ^ thing]
@@ -198,8 +225,21 @@
let decl = Printf.sprintf "%s = { %s }" uname p in
pdecls := decl :: !pdecls;
p ^ "u.__o"
- (* LLVM LOCAL Omit casts so so we get better error messages. *)
- | _ -> (* add_cast t *) p in
+ (* LLVM LOCAL begin Extract vector operand from wrapper struct. *)
+ | T_int8x8 | T_int8x16
+ | T_int16x4 | T_int16x8
+ | T_int32x2 | T_int32x4
+ | T_int64x1 | T_int64x2
+ | T_uint8x8 | T_uint8x16
+ | T_uint16x4 | T_uint16x8
+ | T_uint32x2 | T_uint32x4
+ | T_uint64x1 | T_uint64x2
+ | T_float32x2 | T_float32x4
+ | T_poly8x8 | T_poly8x16
+ | T_poly16x4 | T_poly16x8 ->
+ add_cast_with_prefix t (p ^ ".val") "__neon_"
+ (* LLVM LOCAL end Extract vector operand from wrapper struct. *)
+ | _ -> add_cast t p in
let plist = match ps with
Arity0 _ -> []
| Arity1 (_, t1) -> [ptype t1 "__a"]
@@ -313,49 +353,65 @@
FIXME: It's probably better to use stdint.h names here.
*)
+(* LLVM LOCAL begin Use stdint.h types for elements and add wrapper structs. *)
let deftypes () =
+ (* Extra types not in <stdint.h>. *)
+ Format.printf "typedef float float32_t;\n";
+ Format.printf "typedef signed char poly8_t;\n";
+ Format.printf "typedef signed short poly16_t;\n";
+ Format.print_newline ();
let typeinfo = [
(* Doubleword vector types. *)
- "__builtin_neon_qi", "int", 8, 8;
- "__builtin_neon_hi", "int", 16, 4;
- "__builtin_neon_si", "int", 32, 2;
- "__builtin_neon_di", "int", 64, 1;
- "__builtin_neon_sf", "float", 32, 2;
- "__builtin_neon_poly8", "poly", 8, 8;
- "__builtin_neon_poly16", "poly", 16, 4;
- "__builtin_neon_uqi", "uint", 8, 8;
- "__builtin_neon_uhi", "uint", 16, 4;
- "__builtin_neon_usi", "uint", 32, 2;
- "__builtin_neon_udi", "uint", 64, 1;
+ "int8_t ", "int", 8, 8;
+ "int16_t", "int", 16, 4;
+ "int32_t", "int", 32, 2;
+ "int64_t", "int", 64, 1;
+ "float32_t", "float", 32, 2;
+ "poly8_t", "poly", 8, 8;
+ "poly16_t", "poly", 16, 4;
+ "uint8_t", "uint", 8, 8;
+ "uint16_t", "uint", 16, 4;
+ "uint32_t", "uint", 32, 2;
+ "uint64_t", "uint", 64, 1;
(* Quadword vector types. *)
- "__builtin_neon_qi", "int", 8, 16;
- "__builtin_neon_hi", "int", 16, 8;
- "__builtin_neon_si", "int", 32, 4;
- "__builtin_neon_di", "int", 64, 2;
- "__builtin_neon_sf", "float", 32, 4;
- "__builtin_neon_poly8", "poly", 8, 16;
- "__builtin_neon_poly16", "poly", 16, 8;
- "__builtin_neon_uqi", "uint", 8, 16;
- "__builtin_neon_uhi", "uint", 16, 8;
- "__builtin_neon_usi", "uint", 32, 4;
- "__builtin_neon_udi", "uint", 64, 2
+ "int8_t", "int", 8, 16;
+ "int16_t", "int", 16, 8;
+ "int32_t", "int", 32, 4;
+ "int64_t", "int", 64, 2;
+ "float32_t", "float", 32, 4;
+ "poly8_t", "poly", 8, 16;
+ "poly16_t", "poly", 16, 8;
+ "uint8_t", "uint", 8, 16;
+ "uint16_t", "uint", 16, 8;
+ "uint32_t", "uint", 32, 4;
+ "uint64_t", "uint", 64, 2
] in
List.iter
(fun (cbase, abase, esize, enum) ->
let attr =
match enum with
-(* LLVM LOCAL begin *)
-(* LLVM LOCAL end *)
- _ -> Printf.sprintf "\t__attribute__ ((__vector_size__ (%d)))"
+ (* LLVM LOCAL no special case for enum == 1 so int64x1_t is a vector *)
+ _ -> Printf.sprintf " \t__attribute__ ((__vector_size__ (%d)))"
(esize * enum / 8) in
- Format.printf "typedef %s %s%dx%d_t%s;@\n" cbase abase esize enum attr)
+ Format.printf "typedef %s __neon_%s%dx%d_t%s;@\n" cbase abase esize enum attr)
typeinfo;
Format.print_newline ();
- (* Extra types not in <stdint.h>. *)
- Format.printf "typedef __builtin_neon_sf float32_t;\n";
- Format.printf "typedef __builtin_neon_poly8 poly8_t;\n";
- Format.printf "typedef __builtin_neon_poly16 poly16_t;\n"
+ List.iter
+ (fun (cbase, abase, esize, enum) ->
+ let typename =
+ Printf.sprintf "%s%dx%d_t" abase esize enum in
+ let structname =
+ Printf.sprintf "__simd%d_%s%d_t" (esize * enum) abase esize in
+ let sfmt = start_function () in
+ Format.printf "typedef struct %s" structname;
+ open_braceblock sfmt;
+ Format.printf "__neon_%s val;" typename;
+ close_braceblock sfmt;
+ Format.printf " %s;" typename;
+ end_function sfmt)
+ typeinfo
+(* LLVM LOCAL end Use stdint.h types for elements and add wrapper structs. *)
(* Output structs containing arrays, for load & store instructions etc. *)
Modified: llvm-gcc-4.2/trunk/gcc/config/arm/neon.ml
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/neon.ml?rev=83226&r1=83225&r2=83226&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/arm/neon.ml (original)
+++ llvm-gcc-4.2/trunk/gcc/config/arm/neon.ml Thu Oct 1 19:22:01 2009
@@ -62,18 +62,7 @@
XImode : "heXadeca", eight registers (sixteen words).
*)
-(* LLVM LOCAL begin Use a different type for each vector type. *)
-type inttype = B_TId8mode | B_EId8mode | B_OId8mode
- | B_TId16mode | B_EId16mode | B_OId16mode
- | B_TId32mode | B_EId32mode | B_OId32mode
- | B_TId64mode | B_EId64mode | B_OId64mode
- | B_TIdSFmode | B_EIdSFmode | B_OIdSFmode
- | B_OIq8mode | B_CIq8mode | B_XIq8mode
- | B_OIq16mode | B_CIq16mode | B_XIq16mode
- | B_OIq32mode | B_CIq32mode | B_XIq32mode
- | B_OIq64mode | B_CIq64mode | B_XIq64mode
- | B_OIqSFmode | B_CIqSFmode | B_XIqSFmode
-(* LLVM LOCAL end Use a different type for each vector type. *)
+type inttype = B_TImode | B_EImode | B_OImode | B_CImode | B_XImode
type shape_elt = Dreg | Qreg | Corereg | Immed | VecArray of int * shape_elt
| PtrTo of shape_elt | CstPtrTo of shape_elt
@@ -475,64 +464,17 @@
| T_uint8x16 | T_uint16x8 | T_uint32x4 | T_uint64x2
| T_float32x4 | T_poly8x16 | T_poly16x8 -> 128
| _ -> raise Not_found
-
-(* LLVM LOCAL begin Map vector types to modes. *)
-let vectype_mode = function
- T_int8x8 | T_uint8x8 | T_poly8x8 -> V8QI
- | T_int8x16 | T_uint8x16 | T_poly8x16 -> V16QI
- | T_int16x4 | T_uint16x4 | T_poly16x4 -> V4HI
- | T_int16x8 | T_uint16x8 | T_poly16x8 -> V8HI
- | T_int32x2 | T_uint32x2 -> V2SI
- | T_int32x4 | T_uint32x4 -> V4SI
-(* LLVM LOCAL *)
- | T_int64x1 | T_uint64x1 -> V1DI
- | T_int64x2 | T_uint64x2 -> V2DI
- | T_float32x2 -> V2SF
- | T_float32x4 -> V4SF
- | _ -> raise Not_found
-(* LLVM LOCAL end Map vector types to modes. *)
let inttype_for_array num elttype =
let eltsize = vectype_size elttype in
let numwords = (num * eltsize) / 32 in
- (* LLVM LOCAL begin Match vector type, too. *)
- let vecmode = vectype_mode elttype in
- match numwords, vecmode with
- 4, V8QI -> B_TId8mode
- | 4, V4HI -> B_TId16mode
- | 4, V2SI -> B_TId32mode
-(* LLVM LOCAL *)
- | 4, V1DI -> B_TId64mode
- | 4, V2SF -> B_TIdSFmode
- | 6, V8QI -> B_EId8mode
- | 6, V4HI -> B_EId16mode
- | 6, V2SI -> B_EId32mode
-(* LLVM LOCAL *)
- | 6, V1DI -> B_EId64mode
- | 6, V2SF -> B_EIdSFmode
- | 8, V8QI -> B_OId8mode
- | 8, V4HI -> B_OId16mode
- | 8, V2SI -> B_OId32mode
-(* LLVM LOCAL *)
- | 8, V1DI -> B_OId64mode
- | 8, V2SF -> B_OIdSFmode
- | 8, V16QI -> B_OIq8mode
- | 8, V8HI -> B_OIq16mode
- | 8, V4SI -> B_OIq32mode
- | 8, V2DI -> B_OIq64mode
- | 8, V4SF -> B_OIqSFmode
- | 12, V16QI -> B_CIq8mode
- | 12, V8HI -> B_CIq16mode
- | 12, V4SI -> B_CIq32mode
- | 12, V2DI -> B_CIq64mode
- | 12, V4SF -> B_CIqSFmode
- | 16, V16QI -> B_XIq8mode
- | 16, V8HI -> B_XIq16mode
- | 16, V4SI -> B_XIq32mode
- | 16, V2DI -> B_XIq64mode
- | 16, V4SF -> B_XIqSFmode
+ match numwords with
+ 4 -> B_TImode
+ | 6 -> B_EImode
+ | 8 -> B_OImode
+ | 12 -> B_CImode
+ | 16 -> B_XImode
| _ -> failwith ("no int type for size " ^ string_of_int numwords)
- (* LLVM LOCAL end Match vector type, too. *)
(* These functions return pairs of (internal, external) types, where "internal"
types are those seen by GCC, and "external" are those seen by the assembler.
@@ -1776,39 +1718,12 @@
in
name (fun x -> x ^ "_t") vt
-(* LLVM LOCAL begin Print builtin type names that include the vector type. *)
let string_of_inttype = function
- B_TId8mode -> "__builtin_neon_v8qi2"
- | B_TId16mode -> "__builtin_neon_v4hi2"
- | B_TId32mode -> "__builtin_neon_v2si2"
- | B_TId64mode -> "__builtin_neon_v1di2"
- | B_TIdSFmode -> "__builtin_neon_v2sf2"
- | B_EId8mode -> "__builtin_neon_v8qi3"
- | B_EId16mode -> "__builtin_neon_v4hi3"
- | B_EId32mode -> "__builtin_neon_v2si3"
- | B_EId64mode -> "__builtin_neon_v1di3"
- | B_EIdSFmode -> "__builtin_neon_v2sf3"
- | B_OId8mode -> "__builtin_neon_v8qi4"
- | B_OId16mode -> "__builtin_neon_v4hi4"
- | B_OId32mode -> "__builtin_neon_v2si4"
- | B_OId64mode -> "__builtin_neon_v1di4"
- | B_OIdSFmode -> "__builtin_neon_v2sf4"
- | B_OIq8mode -> "__builtin_neon_v16qi2"
- | B_OIq16mode -> "__builtin_neon_v8hi2"
- | B_OIq32mode -> "__builtin_neon_v4si2"
- | B_OIq64mode -> "__builtin_neon_v2di2"
- | B_OIqSFmode -> "__builtin_neon_v4sf2"
- | B_CIq8mode -> "__builtin_neon_v16qi3"
- | B_CIq16mode -> "__builtin_neon_v8hi3"
- | B_CIq32mode -> "__builtin_neon_v4si3"
- | B_CIq64mode -> "__builtin_neon_v2di3"
- | B_CIqSFmode -> "__builtin_neon_v4sf3"
- | B_XIq8mode -> "__builtin_neon_v16qi4"
- | B_XIq16mode -> "__builtin_neon_v8hi4"
- | B_XIq32mode -> "__builtin_neon_v4si4"
- | B_XIq64mode -> "__builtin_neon_v2di4"
- | B_XIqSFmode -> "__builtin_neon_v4sf4"
-(* LLVM LOCAL end Print builtin type names that include the vector type. *)
+ B_TImode -> "__builtin_neon_ti"
+ | B_EImode -> "__builtin_neon_ei"
+ | B_OImode -> "__builtin_neon_oi"
+ | B_CImode -> "__builtin_neon_ci"
+ | B_XImode -> "__builtin_neon_xi"
let string_of_mode = function
V8QI -> "v8qi" | V4HI -> "v4hi" | V2SI -> "v2si" | V2SF -> "v2sf"
More information about the llvm-commits
mailing list