Path: blob/21.2-virgl/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h
4574 views
/****************************************************************************1* Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*22* @file builder_misc.h23*24* @brief miscellaneous builder functions25*26* Notes:27*28******************************************************************************/29#pragma once3031public:32enum class MEM_CLIENT33{34MEM_CLIENT_INTERNAL,35GFX_MEM_CLIENT_FETCH,36GFX_MEM_CLIENT_SAMPLER,37GFX_MEM_CLIENT_SHADER,38GFX_MEM_CLIENT_STREAMOUT,39GFX_MEM_CLIENT_URB40};4142protected:43virtual Value* OFFSET_TO_NEXT_COMPONENT(Value* base, Constant* offset);44void AssertMemoryUsageParams(Value* ptr, MEM_CLIENT usage);4546public:47virtual Value* GEP(Value* Ptr, Value* Idx, Type* Ty = nullptr, bool isReadOnly = true, const Twine& Name = "");48virtual Value* GEP(Type* Ty, Value* Ptr, Value* Idx, const Twine& Name = "");49virtual Value* GEP(Value* ptr, const std::initializer_list<Value*>& indexList, Type* Ty = nullptr);50virtual Value*51GEP(Value* ptr, const std::initializer_list<uint32_t>& indexList, Type* Ty = nullptr);5253Value* GEPA(Value* Ptr, ArrayRef<Value*> IdxList, const Twine& Name = "");54Value* GEPA(Type* Ty, Value* Ptr, ArrayRef<Value*> IdxList, const Twine& Name = "");5556Value* IN_BOUNDS_GEP(Value* ptr, const std::initializer_list<Value*>& indexList);57Value* IN_BOUNDS_GEP(Value* ptr, const std::initializer_list<uint32_t>& indexList);5859virtual LoadInst*60LOAD(Value* Ptr, const char* Name, Type* Ty = nullptr, MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);61virtual LoadInst* LOAD(Value* Ptr,62const Twine& Name = "",63Type* Ty = nullptr,64MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);65virtual LoadInst*66LOAD(Type* Ty, Value* Ptr, const Twine& Name = "", MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);67virtual LoadInst* LOAD(Value* Ptr,68bool isVolatile,69const Twine& Name = "",70Type* Ty = nullptr,71MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);72virtual LoadInst* LOAD(Value* BasePtr,73const std::initializer_list<uint32_t>& offset,74const llvm::Twine& Name = "",75Type* Ty = nullptr,76MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);7778virtual CallInst* MASKED_LOAD(Value* Ptr,79unsigned Align,80Value* Mask,81Value* PassThru = nullptr,82const Twine& Name = "",83Type* Ty = nullptr,84MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL)85{86return IRB()->CreateMaskedLoad(Ptr, AlignType(Align), Mask, PassThru, Name);87}8889virtual StoreInst* STORE(Value *Val, Value *Ptr, bool isVolatile = false, Type* Ty = nullptr, MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL)90{91return IRB()->CreateStore(Val, Ptr, isVolatile);92}9394virtual StoreInst* STORE(Value* Val, Value* BasePtr, const std::initializer_list<uint32_t>& offset, Type* Ty = nullptr, MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);9596virtual CallInst* MASKED_STORE(Value *Val, Value *Ptr, unsigned Align, Value *Mask, Type* Ty = nullptr, MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL)97{98return IRB()->CreateMaskedStore(Val, Ptr, AlignType(Align), Mask);99}100101LoadInst* LOADV(Value* BasePtr, const std::initializer_list<Value*>& offset, const llvm::Twine& name = "");102StoreInst* STOREV(Value* Val, Value* BasePtr, const std::initializer_list<Value*>& offset);103104Value* MEM_ADD(Value* i32Incr,105Value* basePtr,106const std::initializer_list<uint32_t>& indices,107const llvm::Twine& name = "");108109void Gather4(const SWR_FORMAT format,110Value* pSrcBase,111Value* byteOffsets,112Value* mask,113Value* vGatherComponents[],114bool bPackedOutput,115MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);116117virtual Value* GATHERPS(Value* src,118Value* pBase,119Value* indices,120Value* mask,121uint8_t scale = 1,122MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);123124void GATHER4PS(const SWR_FORMAT_INFO& info,125Value* pSrcBase,126Value* byteOffsets,127Value* mask,128Value* vGatherComponents[],129bool bPackedOutput,130MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);131132virtual Value* GATHERDD(Value* src,133Value* pBase,134Value* indices,135Value* mask,136uint8_t scale = 1,137MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);138139void GATHER4DD(const SWR_FORMAT_INFO& info,140Value* pSrcBase,141Value* byteOffsets,142Value* mask,143Value* vGatherComponents[],144bool bPackedOutput,145MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);146147Value* GATHERPD(Value* src, Value* pBase, Value* indices, Value* mask, uint8_t scale = 1);148149Value* GATHER_PTR(Value* pVecSrcPtr, Value* pVecMask, Value* pVecPassthru);150void SCATTER_PTR(Value* pVecDstPtr, Value* pVecSrc, Value* pVecMask);151152virtual void SCATTERPS(Value* pDst,153Value* vSrc,154Value* vOffsets,155Value* vMask,156MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);157158void Shuffle8bpcGather4(const SWR_FORMAT_INFO& info,159Value* vGatherInput,160Value* vGatherOutput[],161bool bPackedOutput);162void Shuffle16bpcGather4(const SWR_FORMAT_INFO& info,163Value* vGatherInput[],164Value* vGatherOutput[],165bool bPackedOutput);166167// Static stack allocations for scatter operations168Value* pScatterStackSrc{nullptr};169Value* pScatterStackOffsets{nullptr};170171172