]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Merge branch 'master' into blub/bc3
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Thu, 19 Jul 2012 16:06:56 +0000 (18:06 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Thu, 19 Jul 2012 16:06:56 +0000 (18:06 +0200)
1  2 
ir.c

diff --combined ir.c
index e5145cba0bacd2890e24ed51ab8e7aa8f4cba6dd,077ac555c9f42ac20de0b2bcdcfcb2e65f621c9f..d7756bbaea00e12e52287a5b246ef349027c4254
--- 1/ir.c
--- 2/ir.c
+++ b/ir.c
@@@ -41,9 -41,7 +41,9 @@@ size_t type_sizeof[TYPE_COUNT] = 
  #if 0
      1, /* TYPE_INTEGER  */
  #endif
 -    3, /* TYPE_VARIANT  */
 +    4, /* TYPE_QUATERNION */
 +    16, /* TYPE_MATRIX */
 +    16, /* TYPE_VARIANT  */
  };
  
  uint16_t type_store_instr[TYPE_COUNT] = {
      INSTR_STORE_FNC,
      INSTR_STORE_ENT, /* should use I */
  #if 0
 -    INSTR_STORE_ENT, /* integer type */
 +    INSTR_STORE_I, /* integer type */
  #endif
 -    INSTR_STORE_V, /* variant, should never be accessed */
 +    INSTR_STORE_Q,
 +    INSTR_STORE_M,
 +
 +    INSTR_STORE_M, /* variant, should never be accessed */
  };
  
  uint16_t type_storep_instr[TYPE_COUNT] = {
  #if 0
      INSTR_STOREP_ENT, /* integer type */
  #endif
 -    INSTR_STOREP_V, /* variant, should never be accessed */
 +    INSTR_STOREP_Q,
 +    INSTR_STOREP_M,
 +
 +    INSTR_STOREP_M, /* variant, should never be accessed */
  };
  
  MEM_VEC_FUNCTIONS(ir_value_vector, ir_value*, v)
@@@ -575,24 -567,6 +575,24 @@@ bool ir_value_set_vector(ir_value *self
      return true;
  }
  
 +bool ir_value_set_quaternion(ir_value *self, quaternion v)
 +{
 +    if (self->vtype != TYPE_QUATERNION)
 +        return false;
 +    memcpy(&self->constval.vquat, v, sizeof(self->constval.vquat));
 +    self->isconst = true;
 +    return true;
 +}
 +
 +bool ir_value_set_matrix(ir_value *self, matrix v)
 +{
 +    if (self->vtype != TYPE_MATRIX)
 +        return false;
 +    memcpy(&self->constval.vmat, v, sizeof(self->constval.vmat));
 +    self->isconst = true;
 +    return true;
 +}
 +
  bool ir_value_set_string(ir_value *self, const char *str)
  {
      if (self->vtype != TYPE_STRING)
@@@ -896,6 -870,7 +896,6 @@@ bool ir_block_create_storep(ir_block *s
      vtype = what->vtype;
  
      op = type_storep_instr[vtype];
 -
      return ir_block_create_store_op(self, op, target, what);
  }
  
@@@ -1153,6 -1128,7 +1153,6 @@@ ir_value* ir_block_create_binop(ir_bloc
          case INSTR_ADD_V:
          case INSTR_SUB_V:
          case INSTR_MUL_VF:
 -        case INSTR_MUL_FV:
  #if 0
          case INSTR_DIV_VF:
          case INSTR_MUL_IV:
@@@ -1252,8 -1228,6 +1252,8 @@@ ir_value* ir_block_create_load_from_ent
          case TYPE_POINTER: op = INSTR_LOAD_I;   break;
          case TYPE_INTEGER: op = INSTR_LOAD_I;   break;
  #endif
 +        case TYPE_QUATERNION: op = INSTR_LOAD_Q; break;
 +        case TYPE_MATRIX:     op = INSTR_LOAD_M; break;
          default:
              return NULL;
      }
@@@ -1357,22 -1331,12 +1357,22 @@@ ir_value* ir_block_create_mul(ir_block 
              case TYPE_VECTOR:
                  op = INSTR_MUL_V;
                  break;
 +            case TYPE_QUATERNION:
 +                op = INSTR_MUL_Q;
 +                break;
 +            case TYPE_MATRIX:
 +                op = INSTR_MUL_M;
 +                break;
          }
      } else {
          if ( (l == TYPE_VECTOR && r == TYPE_FLOAT) )
              op = INSTR_MUL_VF;
          else if ( (l == TYPE_FLOAT && r == TYPE_VECTOR) )
              op = INSTR_MUL_FV;
 +        else if ( (l == TYPE_QUATERNION && r == TYPE_FLOAT) )
 +            op = INSTR_MUL_QF;
 +        else if ( (l == TYPE_MATRIX && r == TYPE_FLOAT) )
 +            op = INSTR_MUL_MF;
  #if 0
          else if ( (l == TYPE_VECTOR && r == TYPE_INTEGER) )
              op = INSTR_MUL_VI;
@@@ -2440,8 -2404,6 +2440,8 @@@ static bool ir_builder_gen_global(ir_bu
          return global->code.globaladdr >= 0;
      }
      case TYPE_VECTOR:
 +    case TYPE_QUATERNION:
 +    case TYPE_MATRIX:
      {
          size_t d;
          if (code_defs_add(def) < 0)
@@@ -2549,6 -2511,10 +2549,10 @@@ void ir_function_dump(ir_function *f, c
                        int (*oprintf)(const char*, ...))
  {
        size_t i;
+       if (f->builtin != 0) {
+           oprintf("%sfunction %s = builtin %i\n", ind, f->name, -f->builtin);
+           return;
+       }
        oprintf("%sfunction %s\n", ind, f->name);
        strncat(ind, "\t", IND_BUFSZ);
        if (f->locals_count)
@@@ -2652,7 -2618,6 +2656,7 @@@ void ir_value_dump(ir_value* v, int (*o
  {
        if (v->isconst) {
                switch (v->vtype) {
 +                  default:
                        case TYPE_VOID:
                                oprintf("(void)");
                                break;