From 91a2804d8f02955f0cf0dbe83348df9e0958a550 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 10 Jun 2021 20:07:50 -0400 Subject: [PATCH] pan/bi: Move typesize to common code Useful for the opcode table. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_builder.h.py | 15 +-------------- src/panfrost/bifrost/bifrost_isa.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/panfrost/bifrost/bi_builder.h.py b/src/panfrost/bifrost/bi_builder.h.py index 3b7baf1205e..b3ccafd26e8 100644 --- a/src/panfrost/bifrost/bi_builder.h.py +++ b/src/panfrost/bifrost/bi_builder.h.py @@ -58,19 +58,6 @@ def nirtypes(opcode): else: return None -def typesize(opcode): - if opcode[-3:] == '128': - return 128 - if opcode[-2:] == '48': - return 48 - elif opcode[-1] == '8': - return 8 - else: - try: - return int(opcode[-2:]) - except: - return None - def condition(opcode, typecheck, sizecheck): cond = '' if typecheck == True: @@ -211,4 +198,4 @@ def arguments(op, temp_dest = True): modifier_signature(op) + op["immediates"]) -print(Template(COPYRIGHT + TEMPLATE).render(ops = ir_instructions, modifiers = modifier_lists, signature = signature, arguments = arguments, src_count = src_count, SKIP = SKIP)) +print(Template(COPYRIGHT + TEMPLATE).render(ops = ir_instructions, modifiers = modifier_lists, signature = signature, arguments = arguments, src_count = src_count, typesize = typesize, SKIP = SKIP)) diff --git a/src/panfrost/bifrost/bifrost_isa.py b/src/panfrost/bifrost/bifrost_isa.py index 31bb5620ce9..63dd785d513 100644 --- a/src/panfrost/bifrost/bifrost_isa.py +++ b/src/panfrost/bifrost/bifrost_isa.py @@ -334,3 +334,17 @@ def order_modifiers(ir_instructions): def src_count(op): staging = 1 if (op["staging"] in ["r", "rw"]) else 0 return op["srcs"] + staging + +# Parses out the size part of an opocde name +def typesize(opcode): + if opcode[-3:] == '128': + return 128 + if opcode[-2:] == '48': + return 48 + elif opcode[-1] == '8': + return 8 + else: + try: + return int(opcode[-2:]) + except: + return 32