summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorAlok Hota <[email protected]>2018-05-25 10:19:45 -0500
committerTim Rowley <[email protected]>2018-05-25 10:56:37 -0500
commit14b5cac0be15b2a1f6624431ae1b694f3a4487dd (patch)
tree1ac9c03fb6e7f82c2aa95ee62db0d1e9f99e8944 /src/gallium
parentf09636e2e1311b24cbcd2a2d49e97f8a69702cfd (diff)
swr/rast: Use metadata to communicate between passes
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/swr/rasterizer/jitter/builder.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.h b/src/gallium/drivers/swr/rasterizer/jitter/builder.h
index 6ca128d38f1..08a3a6e4734 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder.h
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder.h
@@ -124,6 +124,34 @@ namespace SwrJit
bool SetTexelMaskEvaluate(Instruction* inst);
bool IsTexelMaskEvaluate(Instruction* inst);
Type* GetVectorType(Type* pType);
+ void SetMetadata(StringRef s, uint32_t val)
+ {
+ llvm::NamedMDNode *metaData = mpJitMgr->mpCurrentModule->getOrInsertNamedMetadata(s);
+ Constant* cval = mpIRBuilder->getInt32(val);
+ llvm::MDNode *mdNode = llvm::MDNode::get(mpJitMgr->mpCurrentModule->getContext(), llvm::ConstantAsMetadata::get(cval));
+ if (metaData->getNumOperands())
+ {
+ metaData->setOperand(0, mdNode);
+ }
+ else
+ {
+ metaData->addOperand(mdNode);
+ }
+ }
+ uint32_t GetMetadata(StringRef s)
+ {
+ NamedMDNode* metaData = mpJitMgr->mpCurrentModule->getNamedMetadata(s);
+ if (metaData)
+ {
+ MDNode* mdNode = metaData->getOperand(0);
+ Metadata* val = mdNode->getOperand(0);
+ return mdconst::dyn_extract<ConstantInt>(val)->getZExtValue();
+ }
+ else
+ {
+ return 0;
+ }
+ }
#include "gen_builder.hpp"
#include "gen_builder_meta.hpp"