1/* 2 * Copyright 2017, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef CORE_DEFS_H 18#define CORE_DEFS_H 19 20#include <string> 21 22namespace android { 23namespace spirit { 24 25class Instruction; 26 27typedef int32_t LiteralInteger; 28typedef std::string LiteralString; 29typedef union { 30 int32_t intValue; 31 int64_t longValue; 32 float floatValue; 33 double doubleValue; 34} LiteralContextDependentNumber; 35typedef uint32_t LiteralExtInstInteger; 36typedef uint32_t LiteralSpecConstantOpInteger; 37typedef uint32_t IdResult; 38 39struct IdRef { 40 IdRef() : mId(0), mInstruction(nullptr) {} 41 IdRef(Instruction *inst); 42 43 uint32_t mId; 44 mutable Instruction *mInstruction; 45}; 46 47// TODO: specialize these ref types 48// TODO: should only reference type instructions 49struct IdResultType : public IdRef { 50 IdResultType() : IdRef() {} 51 IdResultType(Instruction *inst) : IdRef(inst) {} 52}; 53 54// TODO: should only reference int representing memory semeantics 55struct IdMemorySemantics : public IdRef {}; 56// TODO: should only reference int representing scopes 57struct IdScope : public IdRef {}; 58 59struct OpCodeAndWordCount { 60 OpCodeAndWordCount() : mOpCode(0) {} 61 OpCodeAndWordCount(uint32_t codeAndCount) 62 : mOpCode((uint16_t)codeAndCount), 63 mWordCount((uint32_t)(codeAndCount >> 16)) {} 64 OpCodeAndWordCount(uint32_t opcode, uint32_t wordCount) 65 : mOpCode((uint16_t)opcode), mWordCount((uint16_t)wordCount) {} 66 67 operator uint32_t() const { 68 return ((uint32_t)mWordCount << 16) | (uint32_t)mOpCode; 69 } 70 71 uint16_t mOpCode; 72 uint16_t mWordCount; 73}; 74 75} // namespace spirit 76} // namespace android 77 78#endif // CORE_DEFS_H 79