Skip to content

Commit ed35a92

Browse files
authored
[clang] Introduce target-specific Sema components (#93179)
This patch introduces `SemaAMDGPU`, `SemaARM`, `SemaBPF`, `SemaHexagon`, `SemaLoongArch`, `SemaMIPS`, `SemaNVPTX`, `SemaPPC`, `SemaSystemZ`, `SemaWasm`. This continues previous efforts to split Sema up. Additional context can be found in #84184 and #92682. I decided to bundle target-specific components together because of their low impact on `Sema`. That said, their impact on `SemaChecking.cpp` is far from low, and I consider it a success. Somewhat accidentally, I also moved Wasm- and AMDGPU-specific function from `SemaDeclAttr.cpp`, because they were exposed in `Sema`. That went well, and I consider it a success, too. I'd like to move the rest of static target-specific functions out of `SemaDeclAttr.cpp` like we're doing with built-ins in `SemaChecking.cpp` .
1 parent b62ba7f commit ed35a92

32 files changed

+4266
-3516
lines changed

.github/new-prs-labeler.yml

+14
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ backend:ARM:
749749
- clang/lib/CodeGen/Targets/ARM.cpp
750750
- clang/include/clang/Basic/BuiltinsARM*
751751
- llvm/test/MC/DisasemblerARM/**
752+
- clang/include/clang/Sema/SemaARM.h
753+
- clang/lib/Sema/SemaARM.cpp
752754

753755
backend:AArch64:
754756
- llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -760,6 +762,8 @@ backend:AArch64:
760762
- clang/lib/CodeGen/Targets/AArch64.cpp
761763
- clang/include/clang/Basic/BuiltinsAArch64*
762764
- llvm/test/MC/Disassembler/AArch64/**
765+
- clang/include/clang/Sema/SemaARM.h
766+
- clang/lib/Sema/SemaARM.cpp
763767

764768
backend:loongarch:
765769
- llvm/include/llvm/IR/IntrinsicsLoongArch.td
@@ -770,6 +774,8 @@ backend:loongarch:
770774
- clang/lib/Driver/ToolChains/Arch/LoongArch.*
771775
- clang/lib/CodeGen/Targets/LoongArch.cpp
772776
- clang/include/clang/Basic/BuiltinsLoongArch*
777+
- clang/include/clang/Sema/SemaLoongArch.h
778+
- clang/lib/Sema/SemaLoongArch.cpp
773779

774780
backend:MSP430:
775781
- llvm/include/llvm/IR/IntrinsicsMSP430.td
@@ -817,6 +823,8 @@ backend:WebAssembly:
817823
- llvm/unittests/Target/WebAssembly/**
818824
- llvm/test/DebugInfo/WebAssembly/**
819825
- llvm/test/MC/WebAssembly/**
826+
- clang/include/clang/Sema/SemaWasm.h
827+
- clang/lib/Sema/SemaLoongWasm.cpp
820828

821829
backend:X86:
822830
- llvm/include/llvm/IR/IntrinsicsX86.td
@@ -836,6 +844,8 @@ backend:X86:
836844
- llvm/include/llvm/TargetParser/X86*
837845
- llvm/lib/TargetParser/X86*
838846
- llvm/utils/TableGen/X86*
847+
- clang/include/clang/Sema/SemaX86.h
848+
- clang/lib/Sema/SemaX86.cpp
839849

840850
backend:PowerPC:
841851
- llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC*
@@ -860,6 +870,8 @@ backend:PowerPC:
860870
- clang/lib/Driver/ToolChains/AIX*
861871
- clang/lib/Driver/ToolChains/Arch/PPC.*
862872
- clang/test/CodeGen/PowerPC/**
873+
- clang/include/clang/Sema/SemaPPC.h
874+
- clang/lib/Sema/SemaPPC.cpp
863875

864876
backend:SystemZ:
865877
- llvm/include/llvm/BinaryFormat/ELFRelocs/SystemZ*
@@ -880,6 +892,8 @@ backend:SystemZ:
880892
- clang/lib/Driver/ToolChains/ZOS*
881893
- clang/lib/Driver/ToolChains/Arch/SystemZ.*
882894
- clang/test/CodeGen/SystemZ/**
895+
- clang/include/clang/Sema/SemaSystemZ.h
896+
- clang/lib/Sema/SemaSystemZ.cpp
883897

884898
third-party:unittests:
885899
- third-party/unittests/**

clang/include/clang/Sema/Attr.h

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===----- Attr.h --- Helper functions for attribute handling in Sema -----===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file provides helpers for Sema functions that handle attributes.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_SEMA_ATTR_H
14+
#define LLVM_CLANG_SEMA_ATTR_H
15+
16+
#include "clang/AST/Decl.h"
17+
#include "clang/AST/DeclBase.h"
18+
#include "llvm/Support/Casting.h"
19+
20+
namespace clang {
21+
22+
/// isFuncOrMethodForAttrSubject - Return true if the given decl has function
23+
/// type (function or function-typed variable) or an Objective-C
24+
/// method.
25+
inline bool isFuncOrMethodForAttrSubject(const Decl *D) {
26+
return (D->getFunctionType() != nullptr) || llvm::isa<ObjCMethodDecl>(D);
27+
}
28+
29+
/// Return true if the given decl has function type (function or
30+
/// function-typed variable) or an Objective-C method or a block.
31+
inline bool isFunctionOrMethodOrBlockForAttrSubject(const Decl *D) {
32+
return isFuncOrMethodForAttrSubject(D) || llvm::isa<BlockDecl>(D);
33+
}
34+
35+
} // namespace clang
36+
#endif // LLVM_CLANG_SEMA_ATTR_H

0 commit comments

Comments
 (0)