Skip to content

Commit 04d2e53

Browse files
scottp101igcbot
authored andcommitted
small code refactor
small code refactor
1 parent 7043085 commit 04d2e53

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

IGC/GenISAIntrinsics/GenIntrinsicFunctions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ SPDX-License-Identifier: MIT
66
77
============================= end_copyright_notice ===========================*/
88

9+
#include "common/igc_regkeys.hpp"
910
#include "GenIntrinsicFunctions.h"
1011
#include "GenIntrinsicDefinition.h"
1112
#include "GenIntrinsicLookup.h"
@@ -197,7 +198,8 @@ template <llvm::GenISAIntrinsic::ID id> class IntrinsicFunctionImp : public llvm
197198
static llvm::AttributeList GetAttributeList(llvm::LLVMContext &ctx,
198199
const llvm::ArrayRef<llvm::Type *> &overloadedPointeeTys) {
199200
// 1. Instantiate regular attributes for the given intrinsic
200-
constexpr auto &attributeKinds = IntrinsicDefinitionT::scAttributeKinds;
201+
llvm::ArrayRef<llvm::Attribute::AttrKind> attributeKinds = IntrinsicDefinitionT::scAttributeKinds;
202+
201203
auto mainAttrList = llvm::AttributeList::get(ctx, llvm::AttributeList::FunctionIndex, attributeKinds);
202204
// 2. Gather the memory attribute(s) in a separate routine
203205
auto memoryAB = IntrinsicDefinitionT::scMemoryEffects.getAsAttrBuilder(ctx);

IGC/GenISAIntrinsics/generator/Intrinsic_definition_objects.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# =========================== end_copyright_notice =============================
88

9-
from typing import List, Set, Optional
9+
from typing import List, Set, Optional, Union
1010
from enum import Enum
1111
import yaml
1212

@@ -593,20 +593,26 @@ class IntrinsicDefinition(SafeYAMLObject):
593593

594594
yaml_tag = u'IntrinsicDefinition'
595595

596+
AttributeSet = Set[Union[AttributeID
597+
]]
598+
596599
@classmethod
597600
def from_yaml(cls, loader, node):
598601
arg_dict = loader.construct_mapping(node, deep=True)
599602
res = cls(**arg_dict)
600603
return res
601604

602605
def __init__(self, name : str, comment : str, return_definition : ReturnDefinition,
603-
arguments : List[ArgumentDefinition], attributes : Set[AttributeID],
606+
arguments : List[ArgumentDefinition], attributes : AttributeSet,
604607
memory_effects : List[MemoryRestriction] = [ MemoryRestriction() ]):
605608
self.name = QuotedString(name)
606609
self.comment = QuotedString(comment)
607610
self.return_definition = return_definition
608611
self.arguments = arguments
609-
self.attributes = sorted(list(attributes), key=lambda x: x.__str__())
612+
613+
self.attributes = [attr for attr in attributes if isinstance(attr, AttributeID)]
614+
self.attributes = sorted(self.attributes, key=lambda x: x.__str__())
615+
610616
if len(memory_effects) > 1:
611617
# TODO: To support LLVM 16-style memory effects per multiple locations,
612618
# we'll need to gather multiple MemoryRestriction entries into a
@@ -616,9 +622,13 @@ def __init__(self, name : str, comment : str, return_definition : ReturnDefiniti
616622
self.memory_effects = memory_effects
617623

618624
def __repr__(self):
619-
return "%s(name=%r, comment=%r, return_definition=%r, arguments=%r, attributes=%r, memory_effects=%r)" % (
625+
fmt_string = "%s(name=%r, comment=%r, return_definition=%r, arguments=%r, attributes=%r"
626+
fmt_string += ", memory_effects=%r)"
627+
return fmt_string % (
620628
self.__class__.__name__, self.name, self.comment, self.return_definition,
621-
self.arguments, self.attributes, self.memory_effects)
629+
self.arguments,
630+
self.attributes,
631+
self.memory_effects)
622632

623633
def to_dict(self):
624634
res = {
@@ -643,7 +653,9 @@ def from_dict(json_dct : dict):
643653
if memory_effects_entry else []
644654
)
645655
return IntrinsicDefinition(json_dct['name'], json_dct['comment'], return_definition,
646-
arguments, attributes, memory_effects)
656+
arguments,
657+
attributes
658+
, memory_effects)
647659

648660
class PrimitiveArgumentDefinition(SafeYAMLObject):
649661

0 commit comments

Comments
 (0)