diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-04-07 17:18:29 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-04-28 15:42:07 -0700 |
commit | 3b96996b7eb6e3603a5f138177867c3e856e0dfa (patch) | |
tree | 0dad0ce7c51cad062115e44fa31b7c798a34052c /ir.cpp | |
parent | bff6013d469b3d4e54cdc5731801c56994a523ec (diff) |
Move array of operator strings out of ir_print_visitor.cpp.
Also implement a reverse-lookup function for use in the IR reader.
Diffstat (limited to 'ir.cpp')
-rw-r--r-- | ir.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -108,6 +108,70 @@ ir_expression::get_num_operands(ir_expression_operation op) return num_operands[op]; } +static const char *const operator_strs[] = { + "~", + "!", + "-", + "abs", + "rcp", + "rsq", + "sqrt", + "exp", + "log", + "exp2", + "log2", + "f2i", + "i2f", + "f2b", + "b2f", + "i2b", + "b2i", + "u2f", + "trunc", + "ceil", + "floor", + "+", + "-", + "*", + "/", + "%", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "<<", + ">>", + "&", + "^", + "|", + "&&", + "^^", + "||", + "dot", + "min", + "max", + "pow", +}; + +const char *ir_expression::operator_string() +{ + assert((unsigned int) operation <= + sizeof(operator_strs) / sizeof(operator_strs[0])); + return operator_strs[operation]; +} + +ir_expression_operation +ir_expression::get_operator(const char *str) +{ + const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); + for (int op = 0; op < operator_count; op++) { + if (strcmp(str, operator_strs[op]) == 0) + return (ir_expression_operation) op; + } + return (ir_expression_operation) -1; +} ir_constant::ir_constant(const struct glsl_type *type, const void *data) { |