1 /****************************************************************************
2 * Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * @file builder_misc.h
25 * @brief miscellaneous builder functions
29 ******************************************************************************/
34 typedef enum _JIT_MEM_CLIENT
38 GFX_MEM_CLIENT_SAMPLER
43 virtual Value
* OFFSET_TO_NEXT_COMPONENT(Value
* base
, Constant
*offset
);
44 void AssertMemoryUsageParams(Value
* ptr
, JIT_MEM_CLIENT usage
);
48 virtual Value
*GEP(Value
*Ptr
, Value
*Idx
, Type
*Ty
= nullptr, const Twine
&Name
= "");
49 virtual Value
*GEP(Type
*Ty
, Value
*Ptr
, Value
*Idx
, const Twine
&Name
= "");
50 virtual Value
*GEP(Value
* ptr
, const std::initializer_list
<Value
*> &indexList
, Type
*Ty
= nullptr);
51 virtual Value
*GEP(Value
* ptr
, const std::initializer_list
<uint32_t> &indexList
, Type
*Ty
= nullptr);
53 Value
*GEPA(Value
*Ptr
, ArrayRef
<Value
*> IdxList
, const Twine
&Name
= "");
54 Value
*GEPA(Type
*Ty
, Value
*Ptr
, ArrayRef
<Value
*> IdxList
, const Twine
&Name
= "");
56 Value
*IN_BOUNDS_GEP(Value
* ptr
, const std::initializer_list
<Value
*> &indexList
);
57 Value
*IN_BOUNDS_GEP(Value
* ptr
, const std::initializer_list
<uint32_t> &indexList
);
59 virtual LoadInst
* LOAD(Value
*Ptr
, const char *Name
, Type
*Ty
= nullptr, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
60 virtual LoadInst
* LOAD(Value
*Ptr
, const Twine
&Name
= "", Type
*Ty
= nullptr, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
61 virtual LoadInst
* LOAD(Type
*Ty
, Value
*Ptr
, const Twine
&Name
= "", JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
62 virtual LoadInst
* LOAD(Value
*Ptr
, bool isVolatile
, const Twine
&Name
= "", Type
*Ty
= nullptr, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
63 virtual LoadInst
* LOAD(Value
*BasePtr
, const std::initializer_list
<uint32_t> &offset
, const llvm::Twine
& Name
= "", Type
*Ty
= nullptr, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
65 virtual CallInst
* MASKED_LOAD(Value
*Ptr
, unsigned Align
, Value
*Mask
, Value
*PassThru
= nullptr, const Twine
&Name
= "", Type
*Ty
= nullptr, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
)
67 return IRB()->CreateMaskedLoad(Ptr
, Align
, Mask
, PassThru
, Name
);
70 LoadInst
*LOADV(Value
*BasePtr
, const std::initializer_list
<Value
*> &offset
, const llvm::Twine
& name
= "");
71 StoreInst
*STORE(Value
*Val
, Value
*BasePtr
, const std::initializer_list
<uint32_t> &offset
);
72 StoreInst
*STOREV(Value
*Val
, Value
*BasePtr
, const std::initializer_list
<Value
*> &offset
);
74 Value
* MEM_ADD(Value
* i32Incr
, Value
* basePtr
, const std::initializer_list
<uint32_t> &indices
, const llvm::Twine
& name
= "");
76 void Gather4(const SWR_FORMAT format
, Value
* pSrcBase
, Value
* byteOffsets
,
77 Value
* mask
, Value
* vGatherComponents
[], bool bPackedOutput
, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
79 virtual Value
*GATHERPS(Value
*src
, Value
*pBase
, Value
*indices
, Value
*mask
, uint8_t scale
= 1, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
81 Value
*GATHERPS_16(Value
*src
, Value
*pBase
, Value
*indices
, Value
*mask
, uint8_t scale
= 1, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
83 void GATHER4PS(const SWR_FORMAT_INFO
&info
, Value
* pSrcBase
, Value
* byteOffsets
,
84 Value
* mask
, Value
* vGatherComponents
[], bool bPackedOutput
, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
86 virtual Value
*GATHERDD(Value
* src
, Value
* pBase
, Value
* indices
, Value
* mask
, uint8_t scale
= 1, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
87 Value
*GATHERDD_16(Value
*src
, Value
*pBase
, Value
*indices
, Value
*mask
, uint8_t scale
= 1, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
89 void GATHER4DD(const SWR_FORMAT_INFO
&info
, Value
* pSrcBase
, Value
* byteOffsets
,
90 Value
* mask
, Value
* vGatherComponents
[], bool bPackedOutput
, JIT_MEM_CLIENT usage
= MEM_CLIENT_INTERNAL
);
92 Value
*GATHERPD(Value
* src
, Value
* pBase
, Value
* indices
, Value
* mask
, uint8_t scale
= 1);
94 Value
*GATHER_PTR(Value
* pVecSrcPtr
, Value
* pVecMask
, Value
* pVecPassthru
);
96 void SCATTERPS(Value
* pDst
, Value
* vSrc
, Value
* vOffsets
, Value
* vMask
);
98 void Shuffle8bpcGather4(const SWR_FORMAT_INFO
&info
, Value
* vGatherInput
, Value
* vGatherOutput
[], bool bPackedOutput
);
99 void Shuffle16bpcGather4(const SWR_FORMAT_INFO
&info
, Value
* vGatherInput
[], Value
* vGatherOutput
[], bool bPackedOutput
);
101 // Static stack allocations for scatter operations
102 Value
* pScatterStackSrc
{ nullptr };
103 Value
* pScatterStackOffsets
{ nullptr };