16 Commits

Author SHA1 Message Date
David Rivera
e3cbd9984a
[CIR][AMDGPU] Lower Language specific address spaces and implement AMDGPU target (#179084) 2026-04-02 03:00:14 -04:00
Chaitanya
83451d8d4d
[CIR][AMDGPU] Add AMDGPU-specific function attributes for HIP kernels (#188007)
Upstreaming clangIR PR: https://github.com/llvm/clangir/pull/2091

This patch adds support for AMDGPU-specific function attributes for HIP
kernels

Added setTargetAttributes for AMDGPUTargetCIRGenInfo to set kernel
attributes
Added generic string attribute handler in amendFunction to translate
string-values with "cir." prefix function attributes to LLVM function
attributes
Follows OGCG AMDGPU implementation from
"clang/lib/CodeGen/Targets/AMDGPU.cpp".
2026-03-27 11:54:29 +05:30
Chaitanya
65d0ef49e1
[CIR][AMDGPU] Add AMDGPU target support to CIR CodeGen (#185819)
This PR adds AMDGPUTargetCIRGenInfo and AMDGPUABIInfo to handle the
amdgcn triple in CIR code generation, along with a
basic HIP codegen test.
2026-03-12 10:20:02 +05:30
Zaky Hermawan
e86d4fb04b
[CIR][CUDA] Handle local, __device__, __shared__, and __constant__ variables (#184248)
Support local, `__device__`, `__shared__`, and `__constant__` variables.
Mark device variables as `externally_initialized`.

References: https://github.com/llvm/llvm-project/issues/175871,
https://github.com/llvm/llvm-project/issues/179278,
https://github.com/llvm/clangir/pull/1368,
https://github.com/llvm/clangir/pull/1394

---------

Signed-off-by: ZakyHermawan <zaky.hermawan9615@gmail.com>
2026-03-11 11:29:34 -07:00
David Rivera
0b88ee12dd
[CIR] Infrastructure and MemorySpaceAttrInterface for Address Spaces (#179073)
Related: https://github.com/llvm/llvm-project/issues/175871,
https://github.com/issues/assigned?issue=llvm%7Cllvm-project%7C179278,
https://github.com/issues/assigned?issue=llvm%7Cllvm-project%7C160386

- Introducing the LangAddressSpace enum with offload address space kinds
(offload_private, offload_local, offload_global, offload_constant,
offload_generic) and the LangAddressSpaceAttr attribute.


- Generalizes CIR AS attributes as MemorySpaceAttrInterface and Attaches
it to `PointerType`. Includes test coverage for valid IR roundtrips and
invalid address space parsing.

This starts a series of patches with the purpose of bringing complete
address spaces support features for CIR. Most of the test coverage is
provided in subsequent patches further down the stack. note that most of
these patches are based on: https://github.com/llvm/clangir/pull/1986
2026-02-27 23:08:20 -05:00
Jameson Nash
d040788af6
[clang] remove unused SrcAddr parameter from performAddrSpaceCast (#179330)
The conversion code always ended up just getting the type of Src from
the Src argument itself, with no virtual users of this, so there is no
point in also providing this API hook. Fix the documentation as well,
since it seems DestAddr must have been similarly removed at some point
in the past from the API but was still documented.

Also fixes CIR to actually return the casted value!
2026-02-05 14:03:19 -05:00
David Rivera
a35b5940b4
[CIR][CUDA][HIP] Add NVPTX target info and CUDA/HIP global emission filtering (#177827)
related: #175871 

This patch adds foundational infra for device-side CUDA/HIP compilation
by introducing NVPTX target info and implementing the global emission
filtering logic.


  NVPTX Target Info to allows us to compile against that triple:
  - Add NVPTXABIInfo and NVPTXTargetCIRGenInfo classes
  - Wire up nvptx and nvptx64 triples in getTargetCIRGenInfo()
  - Add createNVPTXTargetCIRGenInfo() factory function

CUDA/HIP Global Emission Filtering (most of this is boilerplate from the
AST) This basically narrows down to:
- Skip host-only functions (no `__device__` attribute) when
`-fcuda-is-device`
   - Skip device-only functions (device without  host) on host side
- Always emit ` __global__` kernels and `__host__` `__device__`
functions on both sides
- Add `shouldEmitCUDAGlobalVar()` to handle variable emission
(device/constant/shared variables)
- Handle special cases: implicit host/device templates, lambda call
operators
2026-02-03 06:18:39 -05:00
David Rivera
8f9071651d
[CIR] Upstream AddressSpace conversions support (#161212)
related: #160386 
Add support for address space conversions in CIR.

- Added `createAddrSpaceCast` methods to `CIRBaseBuilderTy` to handle
address space conversions
- Implemented address space conversion handling in `emitCastLValue` and
`VisitCastExpr`
- Added `performAddrSpaceCast` method to `TargetCIRGenInfo` for
target-specific address space casting
- Added `getLangTempAllocaAddressSpace` to `CIRGenModule` to get the
language-specific address space for temporary allocations
- Added a test file `address-space-conversion.cpp` to verify address
space conversion functionality
2025-11-12 19:35:45 -05:00
Matheus Izvekov
dc8596d548
[clang] NFC: change more places to use Type::getAsTagDecl and friends (#155313)
This changes a bunch of places which use getAs<TagType>, including
derived types, just to obtain the tag definition.

This is preparation for #155028, offloading all the changes that PR used
to introduce which don't depend on any new helpers.
2025-08-25 20:18:56 -03:00
Amr Hesham
dde474cfc4
[CIR] Make ClangIR compatible with latest nested name specifier AST representation (#152846)
After AST representation, new modifications landed in
(https://github.com/llvm/llvm-project/pull/147835). ClangIR requires
some changes in how we use Clang AST to be compatible with the new
changes
2025-08-11 20:08:37 +02:00
Michael Liao
c9b6242771 [CIR] Fix build after the improved nested name specifier AST repr (91cdd35008e9) 2025-08-09 16:38:49 -04:00
Andres-Salamanca
bd36f7331a
[CIR] Add initial support for bitfields in structs (#142041)
This change adds support for bitfields CIR records can now contain bit
fields.

I’ve updated the `CIRGenBitFieldInfo` comment, which originally came
from the incubator and was identical to the one in OGCodeGen, to better
reflect the current implementation.

Support for bitfields in unions big-endian architectures and `get` and
`set` operations remains unimplemented and will be addressed in a future
patch.
2025-06-20 09:03:02 -05:00
Iris Shi
3f6ef4ecfb
[CIR] Cleanup support for C functions (#136854)
This adds basic handling for non-prototype functions in C.

Closes #130200.
2025-05-13 09:47:21 -07:00
Andy Kaylor
49b79d5367
[CIR][NFC] Remove ABI handling from CIRGen call handling (#139159)
We want to defer ABI handling until we lower to the LLVM dialect. Some
code was in place to calculate ABI handling, but the computed effects
weren't actually used.

This corresponds to the changes made in
https://github.com/llvm/clangir/pull/1604
2025-05-09 12:23:48 -07:00
Sirui Mu
44c4b4cef9
[CIR] Upstream cir.call with scalar arguments (#136810)
This PR upstreams support for scalar arguments in `cir.call` operation.

Related to #132487 .
2025-05-02 10:04:48 +08:00
Sirui Mu
78857e7263
[CIR] cir.call with scalar return type (#135552)
This PR introduces support for calling functions with a scalar return
type to the upstream. This PR also includes an initial version of
`CIRGenTargetInfo` and related definitions which are essential for the
CIRGen of call ops.

Related to #132487 .
2025-04-17 22:38:37 +08:00