gallivm: s/Elements/ARRAY_SIZE/
authorBrian Paul <brianp@vmware.com>
Mon, 25 Apr 2016 21:56:08 +0000 (15:56 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 27 Apr 2016 16:23:19 +0000 (10:23 -0600)
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_assert.c
src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
src/gallium/auxiliary/gallivm/lp_bld_format_cached.c
src/gallium/auxiliary/gallivm/lp_bld_logic.c
src/gallium/auxiliary/gallivm/lp_bld_pack.c
src/gallium/auxiliary/gallivm/lp_bld_printf.c
src/gallium/auxiliary/gallivm/lp_bld_struct.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c

index 17cf296fc20faa3fd996525e8d73c968341f877a..9c78837d78658c34cbeaff24143fe73518d7a9e9 100644 (file)
@@ -3039,7 +3039,7 @@ lp_build_exp2(struct lp_build_context *bld,
    expipart = LLVMBuildBitCast(builder, expipart, vec_type, "");
 
    expfpart = lp_build_polynomial(bld, fpart, lp_build_exp2_polynomial,
-                                  Elements(lp_build_exp2_polynomial));
+                                  ARRAY_SIZE(lp_build_exp2_polynomial));
 
    res = LLVMBuildFMul(builder, expipart, expfpart, "");
 
@@ -3237,7 +3237,7 @@ lp_build_log2_approx(struct lp_build_context *bld,
 
       /* compute P(z) */
       logmant = lp_build_polynomial(bld, z, lp_build_log2_polynomial,
-                                    Elements(lp_build_log2_polynomial));
+                                    ARRAY_SIZE(lp_build_log2_polynomial));
 
       /* logmant = y * P(z) */
       logmant = lp_build_mul(bld, y, logmant);
index 37c142bd2aed55b67f37072f9f6383be008700a9..02755765c0eacb5cac321ac2566510b7af67cafa 100644 (file)
@@ -77,7 +77,7 @@ lp_build_assert(struct gallivm_state *gallivm,
 
    function = lp_build_const_func_pointer(gallivm,
                                           func_to_pointer((func_pointer)lp_assert),
-                                          ret_type, arg_types, Elements(arg_types),
+                                          ret_type, arg_types, ARRAY_SIZE(arg_types),
                                           "assert");
 
    /* build function call param list */
@@ -88,5 +88,5 @@ lp_build_assert(struct gallivm_state *gallivm,
    assert(LLVMTypeOf(args[0]) == arg_types[0]);
    assert(LLVMTypeOf(args[1]) == arg_types[1]);
 
-   LLVMBuildCall(builder, function, args, Elements(args), "");
+   LLVMBuildCall(builder, function, args, ARRAY_SIZE(args), "");
 }
index b921e97e32b995d9f3fffff985f4eaee768bff16..9f6b9e9fb6f060f938cb95e647d6a72a44112460 100644 (file)
@@ -579,7 +579,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
          arg_types[2] = i32t;
          arg_types[3] = i32t;
          function_type = LLVMFunctionType(ret_type, arg_types,
-                                          Elements(arg_types), 0);
+                                          ARRAY_SIZE(arg_types), 0);
 
          /* make const pointer for the C fetch_rgba_8unorm function */
          function = lp_build_const_int_pointer(gallivm,
@@ -617,7 +617,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
             args[3] = LLVMBuildExtractElement(builder, j, index, "");
          }
 
-         LLVMBuildCall(builder, function, args, Elements(args), "");
+         LLVMBuildCall(builder, function, args, ARRAY_SIZE(args), "");
 
          tmp = LLVMBuildLoad(builder, tmp_ptr, "");
 
@@ -686,7 +686,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
          function = lp_build_const_func_pointer(gallivm,
                                                 func_to_pointer((func_pointer) format_desc->fetch_rgba_float),
                                                 ret_type,
-                                                arg_types, Elements(arg_types),
+                                                arg_types, ARRAY_SIZE(arg_types),
                                                 format_desc->short_name);
       }
 
@@ -714,7 +714,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
             args[3] = LLVMBuildExtractElement(builder, j, index, "");
          }
 
-         LLVMBuildCall(builder, function, args, Elements(args), "");
+         LLVMBuildCall(builder, function, args, ARRAY_SIZE(args), "");
 
          tmps[k] = LLVMBuildLoad(builder, tmp_ptr, "");
       }
index b683e7f960c564b76975ce6635d92326520edf48..e08062dcacdc2bf103c39437488f91555a08f9ab 100644 (file)
@@ -90,7 +90,7 @@ store_cached_block(struct gallivm_state *gallivm,
    indices[0] = lp_build_const_int32(gallivm, 0);
    indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_TAGS);
    indices[2] = hash_index;
-   ptr = LLVMBuildGEP(builder, cache, indices, Elements(indices), "");
+   ptr = LLVMBuildGEP(builder, cache, indices, ARRAY_SIZE(indices), "");
    LLVMBuildStore(builder, tag_value, ptr);
 
    indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_DATA);
@@ -98,7 +98,7 @@ store_cached_block(struct gallivm_state *gallivm,
                              lp_build_const_int32(gallivm, 16), "");
    for (count = 0; count < 4; count++) {
       indices[2] = hash_index;
-      ptr = LLVMBuildGEP(builder, cache, indices, Elements(indices), "");
+      ptr = LLVMBuildGEP(builder, cache, indices, ARRAY_SIZE(indices), "");
       ptr = LLVMBuildBitCast(builder, ptr, type_ptr4x32, "");
       LLVMBuildStore(builder, col[count], ptr);
       hash_index = LLVMBuildAdd(builder, hash_index,
@@ -118,7 +118,7 @@ lookup_cached_pixel(struct gallivm_state *gallivm,
    indices[0] = lp_build_const_int32(gallivm, 0);
    indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_DATA);
    indices[2] = index;
-   member_ptr = LLVMBuildGEP(builder, ptr, indices, Elements(indices), "");
+   member_ptr = LLVMBuildGEP(builder, ptr, indices, ARRAY_SIZE(indices), "");
    return LLVMBuildLoad(builder, member_ptr, "cache_data");
 }
 
@@ -134,7 +134,7 @@ lookup_tag_data(struct gallivm_state *gallivm,
    indices[0] = lp_build_const_int32(gallivm, 0);
    indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_TAGS);
    indices[2] = index;
-   member_ptr = LLVMBuildGEP(builder, ptr, indices, Elements(indices), "");
+   member_ptr = LLVMBuildGEP(builder, ptr, indices, ARRAY_SIZE(indices), "");
    return LLVMBuildLoad(builder, member_ptr, "tag_data");
 }
 
@@ -181,7 +181,7 @@ update_cached_block(struct gallivm_state *gallivm,
       arg_types[2] = i32t;
       arg_types[3] = i32t;
       function_type = LLVMFunctionType(ret_type, arg_types,
-                                       Elements(arg_types), 0);
+                                       ARRAY_SIZE(arg_types), 0);
 
       /* make const pointer for the C fetch_rgba_8unorm function */
       function = lp_build_const_int_pointer(gallivm,
@@ -217,7 +217,7 @@ update_cached_block(struct gallivm_state *gallivm,
          args[1] = ptr_addr;
          args[2] = LLVMConstInt(i32t, i, 0);
          args[3] = LLVMConstInt(i32t, j, 0);
-         LLVMBuildCall(builder, function, args, Elements(args), "");
+         LLVMBuildCall(builder, function, args, ARRAY_SIZE(args), "");
       }
    }
 
index 620aece997a4548325d1f68fec580fc37e12deea..a26cc48600374cb2b6a839bfc8290c9a397547ee 100644 (file)
@@ -395,7 +395,7 @@ lp_build_select(struct lp_build_context *bld,
       args[2] = mask;
 
       res = lp_build_intrinsic(builder, intrinsic,
-                               arg_type, args, Elements(args), 0);
+                               arg_type, args, ARRAY_SIZE(args), 0);
 
       if (arg_type != bld->vec_type) {
          res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
index d80c997ad8481e4d695d271a75c549d381a5e515..35b4c5846996f0dba98504b0688180149b970247 100644 (file)
@@ -164,7 +164,7 @@ lp_build_extract_range(struct gallivm_state *gallivm,
    LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
    unsigned i;
 
-   assert(size <= Elements(elems));
+   assert(size <= ARRAY_SIZE(elems));
 
    for (i = 0; i < size; ++i)
       elems[i] = lp_build_const_int32(gallivm, i + start);
@@ -193,7 +193,7 @@ lp_build_concat(struct gallivm_state *gallivm,
    LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH/2];
    LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH];
 
-   assert(src_type.length * num_vectors <= Elements(shuffles));
+   assert(src_type.length * num_vectors <= ARRAY_SIZE(shuffles));
    assert(util_is_power_of_two(num_vectors));
 
    new_length = src_type.length;
@@ -881,7 +881,7 @@ lp_build_pad_vector(struct gallivm_state *gallivm,
    undef      = LLVMGetUndef(type);
    src_length = LLVMGetVectorSize(type);
 
-   assert(dst_length <= Elements(elems));
+   assert(dst_length <= ARRAY_SIZE(elems));
    assert(dst_length >= src_length);
 
    if (src_length == dst_length)
index 69d829ea6762a45956605f39742a8831c4dfced6..14131b39105e677504fbf15f9680b2e31346424f 100644 (file)
@@ -199,7 +199,7 @@ lp_build_printf(struct gallivm_state *gallivm,
    int i;
 
    argcount = lp_get_printf_arg_count(fmt);
-   assert(Elements(params) >= argcount + 1);
+   assert(ARRAY_SIZE(params) >= argcount + 1);
 
    va_start(arglist, fmt);
    for (i = 1; i <= argcount; i++) {
index 0df44164d80c16464c5292fe85284b7561e4f2c1..067740b5c885367a181b3b34b2cab6f5045f971d 100644 (file)
@@ -54,7 +54,7 @@ lp_build_struct_get_ptr(struct gallivm_state *gallivm,
    assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind);
    indices[0] = lp_build_const_int32(gallivm, 0);
    indices[1] = lp_build_const_int32(gallivm, member);
-   member_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, Elements(indices), "");
+   member_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, ARRAY_SIZE(indices), "");
    lp_build_name(member_ptr, "%s.%s_ptr", LLVMGetValueName(ptr), name);
    return member_ptr;
 }
@@ -88,7 +88,7 @@ lp_build_array_get_ptr(struct gallivm_state *gallivm,
    assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
    indices[0] = lp_build_const_int32(gallivm, 0);
    indices[1] = index;
-   element_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, Elements(indices), "");
+   element_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, ARRAY_SIZE(indices), "");
 #ifdef DEBUG
    lp_build_name(element_ptr, "&%s[%s]",
                  LLVMGetValueName(ptr), LLVMGetValueName(index));
index 906a1745551fed9c12e6bd4db797416892d4a22b..f8f43a561c8ed0403f8f9f1e20706d257e21c1d6 100644 (file)
@@ -67,14 +67,14 @@ analyse_src(struct analysis_context *ctx,
    if (!src->Indirect && !src->Absolute && !src->Negate) {
       unsigned swizzle = tgsi_util_get_src_register_swizzle(src, chan);
       if (src->File == TGSI_FILE_TEMPORARY) {
-         if (src->Index < Elements(ctx->temp)) {
+         if (src->Index < ARRAY_SIZE(ctx->temp)) {
             *chan_info = ctx->temp[src->Index][swizzle];
          }
       } else {
          chan_info->file = src->File;
          if (src->File == TGSI_FILE_IMMEDIATE) {
-            assert(src->Index < Elements(ctx->imm));
-            if (src->Index < Elements(ctx->imm)) {
+            assert(src->Index < ARRAY_SIZE(ctx->imm));
+            if (src->Index < ARRAY_SIZE(ctx->imm)) {
                chan_info->u.value = ctx->imm[src->Index][swizzle];
             }
          } else {
@@ -110,7 +110,7 @@ analyse_tex(struct analysis_context *ctx,
    struct lp_tgsi_info *info = ctx->info;
    unsigned chan;
 
-   if (info->num_texs < Elements(info->tex)) {
+   if (info->num_texs < ARRAY_SIZE(info->tex)) {
       struct lp_tgsi_texture_info *tex_info = &info->tex[info->num_texs];
       boolean indirect = FALSE;
       unsigned readmask = 0;
@@ -206,7 +206,7 @@ analyse_sample(struct analysis_context *ctx,
    struct lp_tgsi_info *info = ctx->info;
    unsigned chan;
 
-   if (info->num_texs < Elements(info->tex)) {
+   if (info->num_texs < ARRAY_SIZE(info->tex)) {
       struct lp_tgsi_texture_info *tex_info = &info->tex[info->num_texs];
       unsigned target = ctx->sample_target[inst->Src[1].Register.Index];
       boolean indirect = FALSE;
@@ -301,10 +301,10 @@ analyse_instruction(struct analysis_context *ctx,
 
       if (dst->File == TGSI_FILE_TEMPORARY) {
          regs = ctx->temp;
-         max_regs = Elements(ctx->temp);
+         max_regs = ARRAY_SIZE(ctx->temp);
       } else if (dst->File == TGSI_FILE_OUTPUT) {
          regs = info->output;
-         max_regs = Elements(info->output);
+         max_regs = ARRAY_SIZE(info->output);
       } else if (dst->File == TGSI_FILE_ADDRESS ||
                  dst->File == TGSI_FILE_PREDICATE) {
          continue;
@@ -580,7 +580,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
             const unsigned size =
                   parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
             assert(size <= 4);
-            if (ctx->num_imms < Elements(ctx->imm)) {
+            if (ctx->num_imms < ARRAY_SIZE(ctx->imm)) {
                for (chan = 0; chan < size; ++chan) {
                   float value = parse.FullToken.FullImmediate.u[chan].Float;
                   ctx->imm[ctx->num_imms][chan] = value;