1#ifndef PROTEUS_FRONTEND_VAR_HPP
2#define PROTEUS_FRONTEND_VAR_HPP
7#include <llvm/IR/IRBuilder.h>
8#include <llvm/IR/Module.h>
17template <
typename From,
typename To>
19 static_assert(std::is_arithmetic_v<From>,
"From type must be arithmetic");
20 static_assert(std::is_arithmetic_v<To>,
"To type must be arithmetic");
22 if constexpr (std::is_same_v<From, To>) {
24 }
else if constexpr (std::is_integral_v<From> &&
25 std::is_floating_point_v<To>) {
27 if constexpr (std::is_signed_v<From>) {
32 }
else if constexpr (std::is_floating_point_v<From> &&
33 std::is_integral_v<To>) {
35 if constexpr (std::is_signed_v<To>) {
40 }
else if constexpr (std::is_integral_v<From> && std::is_integral_v<To>) {
45 if constexpr (std::is_signed_v<From>) {
50 }
else if (
ValType->getIntegerBitWidth() >
56 }
else if constexpr (std::is_floating_point_v<From> &&
57 std::is_floating_point_v<To>) {
76 std::unique_ptr<StorageT>
Storage =
nullptr;
94template <
typename T,
typename =
void>
struct Var;
111 Storage =
V.Storage->
clone();
115 std::swap(Storage,
V.Storage);
130 template <
typename U>
133 template <
typename U>
137 template <
typename U>
140 template <
typename U>
144 template <
typename U>
147 template <
typename U>
151 template <
typename U>
154 template <
typename U>
158 template <
typename U>
161 template <
typename U>
191 template <
typename U>
192 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
195 template <
typename U>
196 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
199 template <
typename U>
200 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
203 template <
typename U>
204 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
207 template <
typename U>
208 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
211 template <
typename U>
212 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
215 template <
typename U>
216 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
219 template <
typename U>
220 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
223 template <
typename U>
224 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
227 template <
typename U>
228 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
231 template <
typename U>
232 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
235 template <
typename U>
236 std::enable_if_t<std::is_arithmetic_v<U>,
Var<bool>>
252 template <
typename IdxT>
270 Value *
loadPointer()
const {
return this->Storage->loadPointer(); }
275 template <
typename IdxT>
283 template <
typename OffsetT>
284 std::enable_if_t<std::is_arithmetic_v<OffsetT>,
288 template <
typename OffsetT>
289 std::enable_if_t<std::is_arithmetic_v<OffsetT>,
293 template <
typename OffsetT>
294 friend std::enable_if_t<std::is_arithmetic_v<OffsetT>,
302template <
typename T,
typename U>
303std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U>,
307template <
typename T,
typename U>
308std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U>,
312template <
typename T,
typename U>
313std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U>,
317template <
typename T,
typename U>
318std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U>,
322template <
typename T,
typename U>
323std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U>,
#define PROTEUS_FATAL_ERROR(x)
Definition Error.h:7
Definition VarStorage.hpp:72
Definition VarStorage.hpp:46
Definition VarStorage.hpp:10
virtual std::unique_ptr< VarStorage > clone() const =0
Definition StorageCache.cpp:24
std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U >, Var< std::common_type_t< T, U > > > operator-(const T &ConstValue, const Var< U > &V)
Definition Func.hpp:1180
Value * convert(IRBuilderBase IRB, Value *V)
Definition Var.hpp:18
std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U >, Var< std::common_type_t< T, U > > > operator*(const T &ConstValue, const Var< U > &V)
Definition Func.hpp:1189
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:114
std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U >, Var< std::common_type_t< T, U > > > operator+(const T &ConstValue, const Var< U > &V)
Definition Func.hpp:1172
std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U >, Var< std::common_type_t< T, U > > > operator/(const T &ConstValue, const Var< U > &V)
Definition Func.hpp:1197
std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U >, Var< std::common_type_t< T, U > > > operator%(const T &ConstValue, const Var< U > &V)
Definition Func.hpp:1205
Definition Hashing.hpp:147
Definition TypeMap.hpp:13
Type * getValueType() const
Definition Var.hpp:89
Type * getAllocatedType() const
Definition Var.hpp:90
std::unique_ptr< StorageT > Storage
Definition Var.hpp:76
Value * getSlot() const
Definition Var.hpp:88
Value * loadValue() const
Definition Var.hpp:84
VarStorageOwner(FuncBase &FnIn)
Definition Var.hpp:81
VarStorageOwner(std::unique_ptr< StorageT > StorageIn, FuncBase &FnIn)
Definition Var.hpp:78
void storeValue(Value *Val)
Definition Var.hpp:86
FuncBase & Fn
Definition Var.hpp:75
Var & operator%=(const U &ConstValue)
Var & operator=(const Var< U > &V)
T ValueType
Definition Var.hpp:100
Var & operator=(const U &ConstValue)
Var & operator+=(const Var< U > &Other)
Var & operator+=(const U &ConstValue)
Var(const Var &V)
Definition Var.hpp:110
Var & operator%=(const Var< U > &Other)
Var & operator/=(const U &ConstValue)
T ElemType
Definition Var.hpp:101
Var & operator-=(const Var< U > &Other)
Var & operator-=(const U &ConstValue)
Var(std::unique_ptr< VarStorage > Storage, FuncBase &Fn)
Definition Var.hpp:103
Var(Var &&V)
Definition Var.hpp:114
Var & operator/=(const Var< U > &Other)
Var & operator*=(const Var< U > &Other)
Var & operator*=(const U &ConstValue)
T ValueType
Definition Var.hpp:244
Var< std::add_pointer_t< ValueType > > getAddress() const =delete
Var(std::unique_ptr< ArrayStorage > Storage, FuncBase &Fn)
Definition Var.hpp:247
std::remove_extent_t< T > ElemType
Definition Var.hpp:245
std::enable_if_t< std::is_integral_v< IdxT >, Var< ElemType > > operator[](const Var< IdxT > &Index)
Value * loadPointer() const
Definition Var.hpp:270
std::remove_pointer_t< T > ElemType
Definition Var.hpp:264
friend std::enable_if_t< std::is_arithmetic_v< OffsetT >, Var< T, std::enable_if_t< std::is_pointer_v< T > > > > operator+(OffsetT Offset, const Var &Ptr)
Definition Var.hpp:296
void storePointer(Value *Ptr)
Definition Var.hpp:271
T ValueType
Definition Var.hpp:263
Var(std::unique_ptr< PointerStorage > Storage, FuncBase &Fn)
Definition Var.hpp:266
std::enable_if_t< std::is_arithmetic_v< IdxT >, Var< ElemType > > operator[](const Var< IdxT > &Index)