Skip to content

Commit

Permalink
Apply yapf
Browse files Browse the repository at this point in the history
  • Loading branch information
kito-cheng committed Aug 3, 2024
1 parent a119021 commit 639f9a6
Show file tree
Hide file tree
Showing 23 changed files with 153 additions and 49 deletions.
114 changes: 94 additions & 20 deletions rvv-intrinsic-generator/rvv_intrinsic_gen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,16 @@ def inst_group_epilogue(self):
def func(self, inst_info, name, return_type, **kwargs):
return NotImplemented

def function_group(self, template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=None):
def function_group(self,
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=None):
# pylint: disable=unused-argument
# NOTE: 'title' and 'link' are only used in DocGenerator and
# OverloadedDocGenerator. Probably need some decoupling here.
Expand Down Expand Up @@ -342,8 +350,16 @@ def inst_group_epilogue(self):
self.write(s)
return s

def function_group(self, template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=None):
def function_group(self,
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=None):
self.write_title(title, link)
if self.has_tail_policy and len(decorator_list) == 0:
s = "Intrinsics here don't have a policy variant.\n"
Expand All @@ -353,8 +369,16 @@ def function_group(self, template, title, link, op_list, type_list, sew_list,
self.write("Intrinsics here don't have an overloaded variant.\n")
return

super().function_group(template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=description)
super().function_group(
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=description)

def func(self, inst_info, name, return_type, **kwargs):
name = Generator.func_name(name)
Expand Down Expand Up @@ -389,7 +413,8 @@ def start_group(self, group_name):

def emit_function_group_description(self, description):
if description:
self.write(f"{description}\n");
self.write(f"{description}\n")


class OverloadedDocGenerator(DocGenerator):
"""
Expand All @@ -403,14 +428,30 @@ def write_title(self, text, link):
else:
self.fd.write("\n[[overloaded-" + link + "]]\n==== " + text + "\n")

def function_group(self, template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=None):
def function_group(self,
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=None):
self.do_not_have_overloaded_variant = True
for op in op_list:
if Generator.is_support_overloaded(op):
self.do_not_have_overloaded_variant = False
super().function_group(template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=description)
super().function_group(
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=description)

def func(self, inst_info, name, return_type, **kwargs):
func_name = Generator.func_name(name)
Expand Down Expand Up @@ -664,16 +705,25 @@ def post_gen(self):
self.fd.write(dg_pattern_str)
self.fd.close()

def function_group(self, template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=None):
def function_group(self,
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=None):
self.test_file_names = op_list
template.render(
G=self,
op_list=op_list,
type_list=type_list,
sew_list=sew_list,
lmul_list=lmul_list,
decorator_list=decorator_list, description=description)
decorator_list=decorator_list,
description=description)


class Grouper(Generator):
Expand Down Expand Up @@ -719,8 +769,16 @@ def func(self, inst_info, name, return_type, **kwargs):
def query_group_desc(self, func_name):
return self.func_group[func_name]

def function_group(self, template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=None):
def function_group(self,
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=None):
self.op_list = op_list
self.groups[self.current_group].append(title)
self.current_sub_group = title
Expand Down Expand Up @@ -869,12 +927,28 @@ def inst_group_prologue(self):
def inst_group_epilogue(self):
return ""

def function_group(self, template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=None):
def function_group(self,
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=None):
if self.has_tail_policy and len(decorator_list) == 0:
return
super().function_group(template, title, link, op_list, type_list, sew_list,
lmul_list, decorator_list, description=description)
super().function_group(
template,
title,
link,
op_list,
type_list,
sew_list,
lmul_list,
decorator_list,
description=description)

@staticmethod
def is_policy_func(inst_info):
Expand Down
25 changes: 17 additions & 8 deletions rvv-intrinsic-generator/rvv_intrinsic_gen/inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,16 @@ def gen(g):
####################################################################
g.start_group("Vector Fixed-Point Arithmetic Intrinsics")
vxsat_description = "After executing an intrinsic in this section, " + \
"the `vxsat` CSR assumes an UNSPECIFIED value.";
"the `vxsat` CSR assumes an UNSPECIFIED value."

g.function_group(
binary_op_template,
"Vector Single-Width Saturating Add and Subtract Intrinsics",
"vector-single-width-saturating-add-and-subtract", ["sadd", "ssub"],
ITYPES, SEWS, LMULS, decorators.has_masking_maskedoff_policy,
ITYPES,
SEWS,
LMULS,
decorators.has_masking_maskedoff_policy,
description=vxsat_description)

g.function_group(binary_op_template,
Expand All @@ -257,7 +260,9 @@ def gen(g):
"Vector Single-Width Fractional Multiply with Rounding and Saturation" +
"Intrinsics",
"vector-single-width-fractional-multiply-with-rounding-and-" +
"saturation", ["smul"], ["int"], SEWS, LMULS,
"saturation", ["smul"], ["int"],
SEWS,
LMULS,
decorators.has_masking_maskedoff_policy_vxrm,
description=vxsat_description)

Expand All @@ -267,11 +272,15 @@ def gen(g):
ITYPES, SEWS, LMULS,
decorators.has_masking_maskedoff_policy_vxrm)

g.function_group(binary_nop_template,
"Vector Narrowing Fixed-Point Clip Intrinsics",
"vector-narrowing-fixed-point-clip", ["nclip"], ITYPES,
WSEWS, WLMULS, decorators.has_masking_maskedoff_policy_vxrm,
description=vxsat_description)
g.function_group(
binary_nop_template,
"Vector Narrowing Fixed-Point Clip Intrinsics",
"vector-narrowing-fixed-point-clip", ["nclip"],
ITYPES,
WSEWS,
WLMULS,
decorators.has_masking_maskedoff_policy_vxrm,
description=vxsat_description)

####################################################################
g.start_group("Vector Floating-Point Intrinsics")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from enums import InstType


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def must_int_type(**kargs):


# narrowing op template
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
from enums import ExtraAttr


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from enums import InstType


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from enums import InstType


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
from constants import ITYPES


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name, unused-argument
# FIXME: Renaming 'G' to 'g' all in once later.
# FIXME: Argument 'type_list' is unused but required for interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def vset_constraint(**kargs):
and int(kargs["LMUL"]) > int(kargs["SRC_LMUL"])


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
from enums import ExtraAttr


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from enums import ExtraAttr


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from enums import InstType


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name, unused-argument
# FIXME: Renaming 'G' to 'g' all in once later.
# FIXME: Argument 'lmul_list' is unused but required for interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from enums import InstType


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from generator import CompatibleHeaderGenerator


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from enums import InstType


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from enums import ExtraAttr


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from generator import CompatibleHeaderGenerator


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name, unused-argument
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
from generator import CompatibleHeaderGenerator


def render(G, op_list, type_list, sew_list, lmul_list, decorator_list, description):
def render(G, op_list, type_list, sew_list, lmul_list, decorator_list,
description):
#pylint: disable=invalid-name
# FIXME: Renaming 'G' to 'g' all in once later.
G.emit_function_group_description(description)
Expand Down
Loading

0 comments on commit 639f9a6

Please sign in to comment.