This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 //===-- CValue.h ---------------------------------------------- -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2010, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #ifndef COMMA_CODEGEN_CVALUE_HDR_GUARD 00010 #define COMMA_CODEGEN_CVALUE_HDR_GUARD 00011 00012 #include "llvm/ADT/PointerIntPair.h" 00013 #include "llvm/Value.h" 00014 00015 namespace comma { 00016 00017 //===----------------------------------------------------------------------===// 00018 // CValue 00019 // 00025 class CValue { 00026 00027 public: 00029 CValue() { } 00030 00036 enum Kind { 00037 Simple, 00038 Aggregate, 00039 Fat 00040 }; 00041 00043 00044 llvm::Value *first() { return primary; } 00045 const llvm::Value *first() const { return primary; } 00047 00049 00050 llvm::Value *second() { return secondary.getPointer(); } 00051 const llvm::Value *second() const { return secondary.getPointer(); } 00053 00055 bool isSimple() const { return secondary.getInt() == Simple; } 00056 00058 bool isAggregate() const { return secondary.getInt() == Aggregate; } 00059 00061 bool isArray() const { return isAggregate() && second() != 0; } 00062 00064 bool isFat() const { return secondary.getInt() == Fat; } 00065 00067 00068 static CValue get(llvm::Value *V1) { 00069 return CValue(V1, 0, Simple); 00070 } 00071 00072 static CValue getArray(llvm::Value *V1, llvm::Value *V2) { 00073 return CValue(V1, V2, Aggregate); 00074 } 00075 00076 static CValue getRecord(llvm::Value *V1) { 00077 return CValue(V1, 0, Aggregate); 00078 } 00079 00080 static CValue getFat(llvm::Value *V1) { 00081 return CValue(V1, 0, Fat); 00082 } 00084 00085 private: 00087 CValue(llvm::Value *V1, llvm::Value *V2, Kind kind) 00088 : primary(V1), secondary(V2, kind) { } 00089 00093 llvm::Value *primary; 00094 llvm::PointerIntPair<llvm::Value*, 2, Kind> secondary; 00095 }; 00096 00097 } // end comma namespace. 00098 00099 #endif 00100