Path: blob/21.2-virgl/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.h
4574 views
/****************************************************************************1* Copyright (C) 2014-2018 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_gfx_mem.h23*24* @brief Definition of the builder to support different translation types for gfx memory access25*26* Notes:27*28******************************************************************************/29#pragma once3031#include "builder.h"3233namespace SwrJit34{35using namespace llvm;3637class BuilderGfxMem : public Builder38{39public:40BuilderGfxMem(JitManager* pJitMgr);41virtual ~BuilderGfxMem() {}4243virtual Value* GEP(Value* Ptr, Value* Idx, Type* Ty = nullptr, bool isReadOnly = true, const Twine& Name = "");44virtual Value* GEP(Type* Ty, Value* Ptr, Value* Idx, const Twine& Name = "");45virtual Value*46GEP(Value* Ptr, const std::initializer_list<Value*>& indexList, Type* Ty = nullptr);47virtual Value*48GEP(Value* Ptr, const std::initializer_list<uint32_t>& indexList, Type* Ty = nullptr);4950virtual LoadInst* LOAD(Value* Ptr,51const char* Name,52Type* Ty = nullptr,53MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);54virtual LoadInst* LOAD(Value* Ptr,55const Twine& Name = "",56Type* Ty = nullptr,57MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);58virtual LoadInst* LOAD(Value* Ptr,59bool isVolatile,60const Twine& Name = "",61Type* Ty = nullptr,62MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);63virtual LoadInst* LOAD(Value* BasePtr,64const std::initializer_list<uint32_t>& offset,65const llvm::Twine& Name = "",66Type* Ty = nullptr,67MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);6869virtual CallInst* MASKED_LOAD(Value* Ptr,70unsigned Align,71Value* Mask,72Value* PassThru = nullptr,73const Twine& Name = "",74Type* Ty = nullptr,75MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);7677virtual StoreInst* STORE(Value *Val, Value *Ptr, bool isVolatile = false, Type* Ty = nullptr, MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);7879virtual StoreInst* STORE(Value* Val, Value* BasePtr, const std::initializer_list<uint32_t>& offset, Type* Ty = nullptr, MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);8081virtual CallInst* MASKED_STORE(Value *Val, Value *Ptr, unsigned Align, Value *Mask, Type* Ty = nullptr, MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);8283virtual Value* GATHERPS(Value* src,84Value* pBase,85Value* indices,86Value* mask,87uint8_t scale = 1,88MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);89virtual Value* GATHERDD(Value* src,90Value* pBase,91Value* indices,92Value* mask,93uint8_t scale = 1,94MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);9596virtual void SCATTERPS(Value* pDst,97Value* vSrc,98Value* vOffsets,99Value* vMask,100MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);101102Value* TranslateGfxAddressForRead(Value* xpGfxAddress,103Type* PtrTy = nullptr,104const Twine& Name = "",105MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);106Value* TranslateGfxAddressForWrite(Value* xpGfxAddress,107Type* PtrTy = nullptr,108const Twine& Name = "",109MEM_CLIENT usage = MEM_CLIENT::MEM_CLIENT_INTERNAL);110111protected:112void AssertGFXMemoryParams(Value* ptr, MEM_CLIENT usage);113114virtual void NotifyPrivateContextSet();115116virtual Value* OFFSET_TO_NEXT_COMPONENT(Value* base, Constant* offset);117118Value* TranslationHelper(Value* Ptr, Type* Ty, Value* pfnTranslateGfxAddress);119void TrackerHelper(Value* Ptr, Type* Ty, MEM_CLIENT usage, bool isRead);120121FunctionType* GetTranslationFunctionType() { return mpTranslationFuncTy; }122Value* GetTranslationFunctionForRead() { return mpfnTranslateGfxAddressForRead; }123Value* GetTranslationFunctionForWrite() { return mpfnTranslateGfxAddressForWrite; }124Value* GetParamSimDC() { return mpParamSimDC; }125126Value* mpWorkerData;127128private:129FunctionType* mpTranslationFuncTy;130Value* mpfnTranslateGfxAddressForRead;131Value* mpfnTranslateGfxAddressForWrite;132Value* mpParamSimDC;133Value* mpfnTrackMemAccess;134};135} // namespace SwrJit136137138