Skip to content

Commit

Permalink
WIP experimental targetcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
Diptorup Deb committed Nov 14, 2023
1 parent 2616e5e commit b01c81a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions numba_dpex/experimental/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from functools import cached_property

from llvmlite import ir as llvmir
from numba.core import types
from numba.core.descriptors import TargetDescriptor
from numba.core.types.scalars import IntEnumClass
Expand Down Expand Up @@ -77,6 +78,22 @@ class DpexExpKernelTargetContext(DpexKernelTargetContext):
they are stable enough to be migrated to DpexKernelTargetContext.
"""

def get_getattr(self, typ, attr):
"""
Overrides the get_getattr function to provide an implementation for
getattr call on an IntegerEnumLiteral type.
"""

if isinstance(typ, IntEnumLiteral):
# pylint: disable=W0613
def enum_literal_getattr_imp(context, builder, typ, val, attr):
enum_attr_value = getattr(typ.literal_value, attr).value
return llvmir.Constant(llvmir.IntType(32), enum_attr_value)

return enum_literal_getattr_imp

return super().get_getattr(typ, attr)


class DpexExpKernelTarget(TargetDescriptor):
"""
Expand Down

0 comments on commit b01c81a

Please sign in to comment.