summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr
diff options
context:
space:
mode:
authorGeorge Kyriazis <[email protected]>2018-02-13 19:22:03 -0600
committerGeorge Kyriazis <[email protected]>2018-02-28 11:42:37 -0600
commite2a4fd076167fed786edc9e7acb45b68429c3399 (patch)
tree519cd3b17f698b8f85f93926d34a905ad3fd75ee /src/gallium/drivers/swr
parent190ead3d79f1f4037c08f7d6a87d9a1a955ff30d (diff)
swr/rast: Code generation cleanup
Generate more compact code from gen_llvm.hpp. Reviewed-By: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr')
-rw-r--r--src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp
index d61194dae11..190e660ad1c 100644
--- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp
+++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp
@@ -1,5 +1,5 @@
/****************************************************************************
-* Copyright (C) 2014-2017 Intel Corporation. All Rights Reserved.
+* Copyright (C) 2014-2018 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -39,19 +39,19 @@ namespace SwrJit
%for type in types:
INLINE static StructType *Gen_${type['name']}(JitManager* pJitMgr)
{
+ %if needs_ctx(type):
LLVMContext& ctx = pJitMgr->mContext;
- (void) ctx;
+ %endif
StructType* pRetType = pJitMgr->mpCurrentModule->getTypeByName("${type['name']}");
if (pRetType == nullptr)
{
- std::vector<Type*> members;
- <%
- (max_type_len, max_name_len) = calc_max_len(type['members'])
- %>
- %for member in type['members']:
- /* ${member['name']} ${pad(len(member['name']), max_name_len)}*/ members.push_back(${ member['type'] });
- %endfor
+ std::vector<Type*> members =<% (max_type_len, max_name_len) = calc_max_len(type['members']) %>
+ {
+ %for member in type['members']:
+ /* ${member['name']} ${pad(len(member['name']), max_name_len)}*/ ${member['type']},
+ %endfor
+ };
pRetType = StructType::create(members, "${type['name']}", false);
@@ -59,13 +59,13 @@ namespace SwrJit
llvm::DIBuilder builder(*pJitMgr->mpCurrentModule);
llvm::DIFile* pFile = builder.createFile("${input_file}", "${os.path.normpath(input_dir).replace('\\', '/')}");
- std::vector<std::pair<std::string, uint32_t>> dbgMembers;
- %for member in type['members']:
- dbgMembers.push_back(std::make_pair("${member['name']}", ${ member['lineNum'] }));
- %endfor
-
+ std::vector<std::pair<std::string, uint32_t>> dbgMembers =
+ {
+ %for member in type['members']:
+ std::make_pair("${member['name']}", ${pad(len(member['name']), max_name_len)}${member['lineNum']}),
+ %endfor
+ };
pJitMgr->CreateDebugStructType(pRetType, "${type['name']}", pFile, ${type['lineNum']}, dbgMembers);
-
}
return pRetType;
@@ -80,6 +80,12 @@ namespace SwrJit
<%! # Global function definitions
import os
+ def needs_ctx(struct_type):
+ for m in struct_type.get('members', []):
+ if '(ctx)' in m.get('type', ''):
+ return True
+ return False
+
def calc_max_len(fields):
max_type_len = 0
max_name_len = 0