Skip to content

Commit

Permalink
[clang] Introduce target-specific Sema components (#93179)
Browse files Browse the repository at this point in the history
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` .
  • Loading branch information
Endilll authored May 30, 2024
1 parent b62ba7f commit ed35a92
Show file tree
Hide file tree
Showing 32 changed files with 4,266 additions and 3,516 deletions.
14 changes: 14 additions & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ backend:ARM:
- clang/lib/CodeGen/Targets/ARM.cpp
- clang/include/clang/Basic/BuiltinsARM*
- llvm/test/MC/DisasemblerARM/**
- clang/include/clang/Sema/SemaARM.h
- clang/lib/Sema/SemaARM.cpp

backend:AArch64:
- llvm/include/llvm/IR/IntrinsicsAArch64.td
Expand All @@ -760,6 +762,8 @@ backend:AArch64:
- clang/lib/CodeGen/Targets/AArch64.cpp
- clang/include/clang/Basic/BuiltinsAArch64*
- llvm/test/MC/Disassembler/AArch64/**
- clang/include/clang/Sema/SemaARM.h
- clang/lib/Sema/SemaARM.cpp

backend:loongarch:
- llvm/include/llvm/IR/IntrinsicsLoongArch.td
Expand All @@ -770,6 +774,8 @@ backend:loongarch:
- clang/lib/Driver/ToolChains/Arch/LoongArch.*
- clang/lib/CodeGen/Targets/LoongArch.cpp
- clang/include/clang/Basic/BuiltinsLoongArch*
- clang/include/clang/Sema/SemaLoongArch.h
- clang/lib/Sema/SemaLoongArch.cpp

backend:MSP430:
- llvm/include/llvm/IR/IntrinsicsMSP430.td
Expand Down Expand Up @@ -817,6 +823,8 @@ backend:WebAssembly:
- llvm/unittests/Target/WebAssembly/**
- llvm/test/DebugInfo/WebAssembly/**
- llvm/test/MC/WebAssembly/**
- clang/include/clang/Sema/SemaWasm.h
- clang/lib/Sema/SemaLoongWasm.cpp

backend:X86:
- llvm/include/llvm/IR/IntrinsicsX86.td
Expand All @@ -836,6 +844,8 @@ backend:X86:
- llvm/include/llvm/TargetParser/X86*
- llvm/lib/TargetParser/X86*
- llvm/utils/TableGen/X86*
- clang/include/clang/Sema/SemaX86.h
- clang/lib/Sema/SemaX86.cpp

backend:PowerPC:
- llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC*
Expand All @@ -860,6 +870,8 @@ backend:PowerPC:
- clang/lib/Driver/ToolChains/AIX*
- clang/lib/Driver/ToolChains/Arch/PPC.*
- clang/test/CodeGen/PowerPC/**
- clang/include/clang/Sema/SemaPPC.h
- clang/lib/Sema/SemaPPC.cpp

backend:SystemZ:
- llvm/include/llvm/BinaryFormat/ELFRelocs/SystemZ*
Expand All @@ -880,6 +892,8 @@ backend:SystemZ:
- clang/lib/Driver/ToolChains/ZOS*
- clang/lib/Driver/ToolChains/Arch/SystemZ.*
- clang/test/CodeGen/SystemZ/**
- clang/include/clang/Sema/SemaSystemZ.h
- clang/lib/Sema/SemaSystemZ.cpp

third-party:unittests:
- third-party/unittests/**
Expand Down
36 changes: 36 additions & 0 deletions clang/include/clang/Sema/Attr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===----- Attr.h --- Helper functions for attribute handling in Sema -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file provides helpers for Sema functions that handle attributes.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_SEMA_ATTR_H
#define LLVM_CLANG_SEMA_ATTR_H

#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "llvm/Support/Casting.h"

namespace clang {

/// isFuncOrMethodForAttrSubject - Return true if the given decl has function
/// type (function or function-typed variable) or an Objective-C
/// method.
inline bool isFuncOrMethodForAttrSubject(const Decl *D) {
return (D->getFunctionType() != nullptr) || llvm::isa<ObjCMethodDecl>(D);
}

/// Return true if the given decl has function type (function or
/// function-typed variable) or an Objective-C method or a block.
inline bool isFunctionOrMethodOrBlockForAttrSubject(const Decl *D) {
return isFuncOrMethodForAttrSubject(D) || llvm::isa<BlockDecl>(D);
}

} // namespace clang
#endif // LLVM_CLANG_SEMA_ATTR_H
Loading

0 comments on commit ed35a92

Please sign in to comment.