Commit 8d8afec3 authored by David Woo's avatar David Woo

Code Cleanup

Change-Id: Ied0d2feeda0f6f939543e139446744a32aae61f6
parent 31b96245
......@@ -851,12 +851,6 @@ public:
public:
void ValidateNumberofSources(EOPCODE opCode, uint &numberofSrcs)
{
return m_PayloadMapping.ValidateNumberofSources(opCode, numberofSrcs);
}
uint GetNumPayloadElements(llvm::Instruction *inst)
{
if (currentPart_ == 0)
......
......@@ -5970,6 +5970,7 @@ void EmitPass::interceptSamplePayloadCoalescing(
}
ResourceDescriptor EmitPass::GetSampleResourceHelper(SampleIntrinsic* inst)
{
llvm::Value* texOp = inst->getTextureValue();
......@@ -5980,8 +5981,10 @@ ResourceDescriptor EmitPass::GetSampleResourceHelper(SampleIntrinsic* inst)
void EmitPass::emitSampleInstruction(SampleIntrinsic* inst)
{
EOPCODE opCode = GetOpCode(inst);
ResourceDescriptor resource = GetSampleResourceHelper(inst);
//Get sampler index in the array of operands
llvm::Value* samplerOp = inst->getSamplerValue();
SamplerDescriptor sampler = GetSamplerVariable(samplerOp);
......@@ -9621,11 +9624,6 @@ CVariable* EmitPass::BroadcastAndTruncPointer(CVariable* pVar)
return pVar;
}
void EmitPass::ValidateNumberofSources(EOPCODE opCode, uint &numberofSrcs)
{
PayloadMapping::ValidateNumberofSources(opCode, numberofSrcs);
}
// Method used to emit reads from GS SGV variables that are not per-vertex.
// Only two cases exist: PrimitiveID, GSInstanceID
void EmitPass::emitGS_SGV(SGVIntrinsic* pInst)
......
......@@ -175,6 +175,7 @@ public:
CVariable*& outputDepthOpnd,
CVariable*& vStencilOpnd);
ResourceDescriptor GetSampleResourceHelper(llvm::SampleIntrinsic* inst);
void interceptSamplePayloadCoalescing(
......@@ -398,7 +399,6 @@ public:
CVariable* TruncatePointer(CVariable* pVar);
CVariable* ReAlignUniformVariable(CVariable *pVar, e_alignment align = EALIGN_GRF);
CVariable* BroadcastAndTruncPointer(CVariable* pVar);
void ValidateNumberofSources(EOPCODE opCode, uint &numberofSrcs);
CVariable* IndexableResourceIndex(CVariable* indexVar, uint btiIndex);
ResourceDescriptor GetResourceVariable(llvm::Value* resourcePtr);
SamplerDescriptor GetSamplerVariable(llvm::Value* samplerPtr);
......
......@@ -274,8 +274,13 @@ bool PayloadMapping::HasNonHomogeneousPayloadElements_RTWrite(const Instruction
}
/// \brief
bool PayloadMapping::IsZeroImmediate(const Value* value)
bool PayloadMapping::IsUndefOrZeroImmediate(const Value* value)
{
if (llvm::isa<llvm::UndefValue>(value))
{
return true;
}
if (const llvm::ConstantInt *CInt = llvm::dyn_cast<llvm::ConstantInt>(value)){
if (CInt->getZExtValue() == 0){
return true;
......@@ -333,7 +338,7 @@ uint PayloadMapping::GetNumPayloadElements_LDMS(const GenIntrinsicInst *inst)
for (uint i = numSources - 1; i > 0; i--)
{
if (IsZeroImmediate(inst->getOperand(i)))
if (IsUndefOrZeroImmediate(inst->getOperand(i)))
{
numSources--;
}
......@@ -441,7 +446,7 @@ uint PayloadMapping::GetNonAdjustedNumPayloadElements_Sample(const SampleIntrins
//Check for valid number of sources from the end of the list
for (uint i = (numSources - 1); i >= 1; i--)
{
if (IsZeroImmediate(inst->getOperand(i)))
if (IsUndefOrZeroImmediate(inst->getOperand(i)))
{
numSources--;
}
......@@ -452,8 +457,7 @@ uint PayloadMapping::GetNonAdjustedNumPayloadElements_Sample(const SampleIntrins
}
//temp solution to send valid sources but having 0 as their values.
SampleIntrinsic *sampleInst = (SampleIntrinsic *)inst;
EOPCODE opCode = GetOpCode(sampleInst);
EOPCODE opCode = GetOpCode(inst);
ValidateNumberofSources(opCode, numSources);
if (IsZeroLOD(inst))
......
......@@ -100,7 +100,7 @@ protected:
bool HasNonHomogeneousPayloadElements_RTWrite(const llvm::Instruction *inst);
/// ------------------------------
bool IsZeroImmediate(const llvm::Value* value);
bool IsUndefOrZeroImmediate(const llvm::Value* value);
bool IsZeroLOD(const llvm::SampleIntrinsic *inst);
bool DoPeelFirstElement(const llvm::Instruction *inst);
......
......@@ -330,6 +330,7 @@ inline void AddLegalizationPasses(CodeGenContext &ctx, const CShaderProgram::Ker
initializeSimd32ProfitabilityAnalysisPass(*PassRegistry::getPassRegistry());
initializeGenXFunctionGroupAnalysisPass(*PassRegistry::getPassRegistry());
if (ctx.type == ShaderType::PIXEL_SHADER)
{
mpm.add(new DiscardLowering());
......
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
#include "FixSampleDInputs.h"
#include "common/LLVMWarningsPush.hpp"
#include <llvm/IR/Instruction.h>
#include <llvm/IR/BasicBlock.h>
#include "common/LLVMWarningsPop.hpp"
#include "GenISAIntrinsics/GenIntrinsics.h"
#include "GenISAIntrinsics/GenIntrinsicInst.h"
#include "Compiler/CodeGenPublic.h"
using namespace llvm;
namespace IGC
{
class FixSampleDInputsPass : public FunctionPass
{
public:
FixSampleDInputsPass() :
FunctionPass(ID)
{ }
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const override
{
AU.setPreservesCFG();
}
virtual StringRef getPassName() const { return "FixSampleDInputs"; }
static char ID;
};
bool FixSampleDInputsPass::runOnFunction(Function &F)
{
bool changed = false;
Module* M = F.getParent();
Type* volumeTextureType = GetResourceDimensionType(*M, RESOURCE_DIMENSION_TYPE::DIM_3D_TYPE);
Type* cubeTextureType = GetResourceDimensionType(*M, RESOURCE_DIMENSION_TYPE::DIM_CUBE_TYPE);
Type* cubeArrayTextureType = GetResourceDimensionType(*M, RESOURCE_DIMENSION_TYPE::DIM_CUBE_ARRAY_TYPE);
for (BasicBlock& BB : F)
{
for (Instruction& inst : BB)
{
SampleIntrinsic* sampleInst = dyn_cast<SampleIntrinsic>(&inst);
Type* textureType = sampleInst ? sampleInst->getTextureValue()->getType()->getPointerElementType() : nullptr;
if (sampleInst &&
sampleInst->getIntrinsicID() == GenISAIntrinsic::GenISA_sampleDptr &&
(textureType != volumeTextureType && textureType != cubeTextureType && textureType != cubeArrayTextureType))
{
changed = true;
sampleInst->setArgOperand(7, sampleInst->getArgOperand(10));
sampleInst->setArgOperand(10, ConstantFP::get(sampleInst->getArgOperand(0)->getType(), 0.0));
}
}
}
return changed;
}
char FixSampleDInputsPass::ID = 0;
FunctionPass* createFixSampleDInputsPass()
{
return new FixSampleDInputsPass();
}
}
\ No newline at end of file
/*===================== begin_copyright_notice ==================================
Copyright (c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================= end_copyright_notice ==================================*/
#pragma once
#include "common/LLVMWarningsPush.hpp"
#include <llvm/Pass.h>
#include "common/LLVMWarningsPop.hpp"
namespace IGC
{
llvm::FunctionPass* createFixSampleDInputsPass();
}
\ No newline at end of file
......@@ -63,6 +63,7 @@ inline bool genplatform::hasSupportforTenBitFloatConversion() const
return false;
}
class SampleParamsFromCube
{
public:
......@@ -408,6 +409,11 @@ public:
llvm::Value* int32_textureIdx,
llvm::Value* int32_sampler);
llvm::CallInst* Create_SAMPLED(
SampleD_DC_FromCubeParams& sampleParams,
llvm::Value* minlod = nullptr,
bool feedback_enabled = false,
llvm::Type* returnType = nullptr);
llvm::CallInst* Create_SAMPLED(
llvm::Value* float_src1_s_chan0,
......@@ -449,6 +455,8 @@ public:
llvm::Value* int32_offsetW,
llvm::Type* returnType = nullptr);
SampleD_DC_FromCubeParams Prepare_SAMPLE_D_DC_Cube_Params(SampleD_DC_FromCubeParams& params);
SampleD_DC_FromCubeParams Prepare_SAMPLE_D_DC_Cube_Params(
llvm::Value* float_src_x,
llvm::Value* float_src_y,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment