[Mesa-stable] [PATCH 1/2] swr/rast: don't create wrapper for every Create LLVM call
Emil Velikov
emil.l.velikov at gmail.com
Mon Feb 4 09:20:46 UTC 2019
We user only a fraction (approximatelly 1/4) of the API - generate only
those.
This way, we spend less time processing and generate smaller file. This
also removes the need for hacks needed for compiling files bootstrapped
with another LLVM version.
Cc: Alok Hota <alok.hota at intel.com>
Cc: Bruce Cherniak <bruce.cherniak at intel.com>
Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
.../rasterizer/codegen/gen_llvm_ir_macros.py | 226 +++++++++++-------
1 file changed, 136 insertions(+), 90 deletions(-)
diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py
index 485403ae1ec..16872411408 100644
--- a/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py
+++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py
@@ -41,6 +41,72 @@ inst_aliases = {
'BIN_OP': 'BINOP',
}
+used_functions = [
+ 'CreateAdd',
+ 'CreateAlloca',
+ 'CreateAnd',
+ 'CreateAShr',
+ 'CreateBitCast',
+ 'CreateBr',
+ 'CreateCall',
+ 'CreateCast',
+ 'CreateCondBr',
+ 'CreateExtractElement',
+ 'CreateFAdd',
+ 'CreateFCmpOEQ',
+ 'CreateFCmpOGE',
+ 'CreateFCmpOGT',
+ 'CreateFCmpOLE',
+ 'CreateFCmpOLT',
+ 'CreateFCmpONE',
+ 'CreateFDiv',
+ 'CreateFMul',
+ 'CreateFPExt',
+ 'CreateFPToSI',
+ 'CreateFPToUI',
+ 'CreateFPTrunc',
+ 'CreateFSub',
+ 'CreateICmpEQ',
+ 'CreateICmpNE',
+ 'CreateICmpSGT',
+ 'CreateICmpSLE',
+ 'CreateICmpSLT',
+ 'CreateICmpUGE',
+ 'CreateICmpUGT',
+ 'CreateICmpULE',
+ 'CreateICmpULT',
+ 'CreateInBoundsGEP',
+ 'CreateInsertElement',
+ 'CreateInsertElement',
+ 'CreateIntToPtr',
+ 'CreateLShr',
+ 'CreateMaskedGather',
+ 'CreateMaskedStore',
+ 'CreateMemSet',
+ 'CreateMul',
+ 'CreateNot',
+ 'CreateOr',
+ 'CreatePHI',
+ 'CreatePointerCast',
+ 'CreatePtrToInt',
+ 'CreateRetVoid',
+ 'CreateSDiv',
+ 'CreateSelect',
+ 'CreateSExt',
+ 'CreateShl',
+ 'CreateShuffleVector',
+ 'CreateSIToFP',
+ 'CreateStore',
+ 'CreateSub',
+ 'CreateTrunc',
+ 'CreateUDiv',
+ 'CreateUIToFP',
+ 'CreateURem',
+ 'CreateVectorSplat',
+ 'CreateXor',
+ 'CreateZExt',
+]
+
intrinsics = [
['VGATHERPD', ['src', 'pBase', 'indices', 'mask', 'scale'], 'src'],
['VGATHERPS', ['src', 'pBase', 'indices', 'mask', 'scale'], 'src'],
@@ -100,97 +166,77 @@ def parse_ir_builder(input_file):
line = lines[idx].rstrip()
idx += 1
- #match = re.search(r'\*Create', line)
match = re.search(r'[\*\s]Create(\w*)\(', line)
- if match is not None:
- #print('Line: %s' % match.group(1))
-
- if re.search(r'^\s*Create', line) is not None:
- func_sig = lines[idx-2].rstrip() + line
- else:
- func_sig = line
-
- end_of_args = False
- while not end_of_args:
- end_paren = re.search(r'\)', line)
- if end_paren is not None:
- end_of_args = True
- else:
- line = lines[idx].rstrip()
- func_sig += line
- idx += 1
-
- delfunc = re.search(r'LLVM_DELETED_FUNCTION|= delete;', func_sig)
-
- if not delfunc:
- func = re.search(r'(.*?)\*[\n\s]*(Create\w*)\((.*?)\)', func_sig)
- if func is not None:
-
- return_type = func.group(1).strip() + '*'
- func_name = func.group(2)
- arguments = func.group(3)
-
- func_args = []
- arg_names = []
- args = arguments.split(',')
- for arg in args:
- arg = arg.strip()
- if arg:
- func_args.append(arg)
-
- split_args = arg.split('=')
- arg_name = split_args[0].rsplit(None, 1)[-1]
-
- reg_arg = re.search(r'[\&\*]*(\w*)', arg_name)
- if reg_arg:
- arg_names += [reg_arg.group(1)]
-
- ignore = False
-
- # The following functions need to be ignored in openswr.
- # API change in llvm-5.0 breaks baked autogen files
- if (
- (func_name == 'CreateFence' or
- func_name == 'CreateAtomicCmpXchg' or
- func_name == 'CreateAtomicRMW')):
- ignore = True
-
- # The following functions need to be ignored.
- if (func_name == 'CreateInsertNUWNSWBinOp' or
- func_name == 'CreateMaskedIntrinsic' or
- func_name == 'CreateAlignmentAssumptionHelper' or
- func_name == 'CreateGEP' or
- func_name == 'CreateLoad' or
- func_name == 'CreateMaskedLoad' or
- func_name == 'CreateElementUnorderedAtomicMemCpy'):
- ignore = True
-
- # Convert CamelCase to CAMEL_CASE
- func_mod = re.search(r'Create(\w*)', func_name)
- if func_mod:
- func_mod = func_mod.group(1)
- func_mod = convert_uppercamel(func_mod)
- if func_mod[0:2] == 'F_' or func_mod[0:2] == 'I_':
- func_mod = func_mod[0] + func_mod[2:]
-
- # Substitute alias based on CAMEL_CASE name.
- func_alias = inst_aliases.get(func_mod)
- if not func_alias:
- func_alias = func_mod
-
- if func_name == 'CreateCall' or func_name == 'CreateGEP':
- arglist = re.search(r'ArrayRef', ', '.join(func_args))
- if arglist:
- func_alias = func_alias + 'A'
-
- if not ignore:
- functions.append({
- 'name' : func_name,
- 'alias' : func_alias,
- 'return' : return_type,
- 'args' : ', '.join(func_args),
- 'arg_names' : arg_names,
- })
+ if match is None:
+ continue
+
+ if re.search(r'^\s*Create', line) is not None:
+ func_sig = lines[idx-2].rstrip() + line
+ else:
+ func_sig = line
+
+ while True:
+ end_paren = re.search(r'\)', line)
+ if end_paren is not None:
+ break
+ line = lines[idx].rstrip()
+ func_sig += line
+ idx += 1
+
+ delfunc = re.search(r'LLVM_DELETED_FUNCTION|= delete;', func_sig)
+
+ if delfunc:
+ continue
+
+ func = re.search(r'(.*?)\*[\n\s]*(Create\w*)\((.*?)\)', func_sig)
+ if func is None:
+ continue
+
+ return_type = func.group(1).strip() + '*'
+ func_name = func.group(2)
+ arguments = func.group(3)
+
+ # Skip functions we don't care about
+ if func_name not in used_functions:
+ continue
+
+ func_args = []
+ arg_names = []
+ args = arguments.split(',')
+ for arg in args:
+ arg = arg.strip()
+ if arg:
+ func_args.append(arg)
+
+ split_args = arg.split('=')
+ arg_name = split_args[0].rsplit(None, 1)[-1]
+
+ reg_arg = re.search(r'[\&\*]*(\w*)', arg_name)
+ if reg_arg:
+ arg_names += [reg_arg.group(1)]
+
+ # Convert CamelCase to CAMEL_CASE
+ func_mod = convert_uppercamel(func_name.replace('Create', ''))
+ if func_mod[0:2] == 'F_' or func_mod[0:2] == 'I_':
+ func_mod = func_mod[0] + func_mod[2:]
+
+ # Substitute alias based on CAMEL_CASE name.
+ func_alias = inst_aliases.get(func_mod)
+ if not func_alias:
+ func_alias = func_mod
+
+ if func_name == 'CreateCall':
+ arglist = re.search(r'ArrayRef', ', '.join(func_args))
+ if arglist:
+ func_alias = func_alias + 'A'
+
+ functions.append({
+ 'name' : func_name,
+ 'alias' : func_alias,
+ 'return' : return_type,
+ 'args' : ', '.join(func_args),
+ 'arg_names' : arg_names,
+ })
return functions
--
2.20.1
More information about the mesa-stable
mailing list