OLD | NEW |
(Empty) | |
| 1 //===- subzero/src/IceIntrinsics.cpp - Functions related to intrinsics ----===// |
| 2 // |
| 3 // The Subzero Code Generator |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // This file implements the Intrinsics utilities for matching and |
| 11 // then dispatching by name. |
| 12 // |
| 13 //===----------------------------------------------------------------------===// |
| 14 |
| 15 #include "IceCfg.h" |
| 16 #include "IceCfgNode.h" |
| 17 #include "IceIntrinsics.h" |
| 18 #include "IceLiveness.h" |
| 19 #include "IceOperand.h" |
| 20 |
| 21 #include <utility> |
| 22 |
| 23 namespace Ice { |
| 24 |
| 25 const IntrinsicInfo UnknownIntrinsicInfo = { UnknownIntrinsic, false }; |
| 26 |
| 27 bool operator==(const IntrinsicInfo &A, const IntrinsicInfo &B) { |
| 28 return A.ID == B.ID && A.HasSideEffects == B.HasSideEffects; |
| 29 } |
| 30 |
| 31 namespace { |
| 32 |
| 33 // TODO(jvoung): vet and test the HasSideEffects attributes. |
| 34 // Reduce the amount of duplication for overloaded intrinsics. |
| 35 const struct IceIntrinsicsEntry_ { |
| 36 IntrinsicInfo Info; |
| 37 const char *IntrinsicName; |
| 38 } IceIntrinsicsTable [] = { |
| 39 { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i8" }, |
| 40 { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i16" }, |
| 41 { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i32" }, |
| 42 { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i64" }, |
| 43 { {AtomicFence, true}, "nacl.atomic.fence"}, |
| 44 { {AtomicFenceAll, true}, "nacl.atomic.fence.all" }, |
| 45 { {AtomicIsLockFree, true}, "nacl.atomic.is.lock.free" }, |
| 46 { {AtomicLoad, true}, "nacl.atomic.load.i8" }, |
| 47 { {AtomicLoad, true}, "nacl.atomic.load.i16" }, |
| 48 { {AtomicLoad, true}, "nacl.atomic.load.i32" }, |
| 49 { {AtomicLoad, true}, "nacl.atomic.load.i64" }, |
| 50 { {AtomicRMW, true}, "nacl.atomic.rmw.i8" }, |
| 51 { {AtomicRMW, true}, "nacl.atomic.rmw.i16" }, |
| 52 { {AtomicRMW, true}, "nacl.atomic.rmw.i32" }, |
| 53 { {AtomicRMW, true}, "nacl.atomic.rmw.i64" }, |
| 54 { {AtomicStore, true}, "nacl.atomic.store.i8" }, |
| 55 { {AtomicStore, true}, "nacl.atomic.store.i16" }, |
| 56 { {AtomicStore, true}, "nacl.atomic.store.i32" }, |
| 57 { {AtomicStore, true}, "nacl.atomic.store.i64" }, |
| 58 { {Bswap, false}, "bswap.i16" }, |
| 59 { {Bswap, false}, "bswap.i32" }, |
| 60 { {Bswap, false}, "bswap.i64" }, |
| 61 { {Ctlz, false}, "ctlz.i32" }, |
| 62 { {Ctlz, false}, "ctlz.i64" }, |
| 63 { {Ctpop, false}, "ctpop.i32" }, |
| 64 { {Ctpop, false}, "ctpop.i64" }, |
| 65 { {Cttz, false}, "cttz.i32" }, |
| 66 { {Cttz, false}, "cttz.i64" }, |
| 67 { {Longjmp, true}, "nacl.longjmp" }, |
| 68 { {Memcpy, true}, "memcpy.p0i8.p0i8.i32" }, |
| 69 { {Memmove, true}, "memmove.p0i8.p0i8.i32" }, |
| 70 { {Memset, true}, "memset.p0i8.i32" }, |
| 71 { {NaClReadTP, false}, "nacl.read.tp" }, |
| 72 { {Setjmp, true}, "nacl.setjmp" }, |
| 73 { {Sqrt, false}, "sqrt.f32" }, |
| 74 { {Sqrt, false}, "sqrt.f64" }, |
| 75 { {Stacksave, true}, "stacksave" }, |
| 76 { {Stackrestore, true}, "stackrestore" }, |
| 77 { {Trap, true}, "trap" } |
| 78 }; |
| 79 const size_t IceIntrinsicsTableSize = llvm::array_lengthof(IceIntrinsicsTable); |
| 80 |
| 81 } // end of namespace |
| 82 |
| 83 void BuildIntrinsicMap(IntrinsicMap *OutMap) { |
| 84 for (size_t I = 0; I < IceIntrinsicsTableSize; ++I) { |
| 85 const struct IceIntrinsicsEntry_ &Entry = IceIntrinsicsTable[I]; |
| 86 OutMap->insert(std::make_pair(IceString(Entry.IntrinsicName), Entry.Info)); |
| 87 } |
| 88 } |
| 89 |
| 90 } // end of namespace Ice |
OLD | NEW |