core_defs.h revision 4df77d18bf57187f8e7142c6f7a70a9cdd3d581e
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 20namespace android { 21namespace spirit { 22 23class Instruction; 24 25typedef int32_t LiteralInteger; 26typedef const char *LiteralString; 27typedef union { 28 int32_t intValue; 29 int64_t longValue; 30 float floatValue; 31 double doubleValue; 32} LiteralContextDependentNumber; 33typedef uint32_t LiteralExtInstInteger; 34typedef uint32_t LiteralSpecConstantOpInteger; 35typedef uint32_t IdResult; 36 37struct IdRef { 38 IdRef() : mId(0), mInstruction(nullptr) {} 39 IdRef(Instruction *inst); 40 41 uint32_t mId; 42 mutable Instruction *mInstruction; 43}; 44 45// TODO: specialize these ref types 46// TODO: should only reference type instructions 47struct IdResultType : public IdRef { 48 IdResultType() : IdRef() {} 49 IdResultType(Instruction *inst) : IdRef(inst) {} 50}; 51 52// TODO: should only reference int representing memory semeantics 53struct IdMemorySemantics : public IdRef {}; 54// TODO: should only reference int representing scopes 55struct IdScope : public IdRef {}; 56 57struct OpCodeAndWordCount { 58 OpCodeAndWordCount() : mOpCode(0) {} 59 OpCodeAndWordCount(uint32_t codeAndCount) 60 : mOpCode((uint16_t)codeAndCount), 61 mWordCount((uint32_t)(codeAndCount >> 16)) {} 62 OpCodeAndWordCount(uint32_t opcode, uint32_t wordCount) 63 : mOpCode((uint16_t)opcode), mWordCount((uint16_t)wordCount) {} 64 65 operator uint32_t() const { 66 return ((uint32_t)mWordCount << 16) | (uint32_t)mOpCode; 67 } 68 69 uint16_t mOpCode; 70 uint16_t mWordCount; 71}; 72 73} // namespace spirit 74} // namespace android 75 76#endif // CORE_DEFS_H 77