Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
47d66bf
[X86] Add tests showing failure to concat fcmp instructions together …
RKSimon Dec 2, 2025
25b6a15
GlobalISel: Stop using TPC to check if GlobalISelAbort is enabled (#1…
petar-avramovic Dec 2, 2025
cdc4147
[lldb][shell tests] Properly fix fallout from c8031c3dd743
felipepiovezan Dec 2, 2025
0d853ae
AMDGPU: Fix treating unknown mem operands as uniform (#170309)
arsenm Dec 2, 2025
e07e60e
libclc: Fix build in atomic_def.inc (#170306)
arsenm Dec 2, 2025
c21fd44
[clang][deps][NFC] Replace a vector with an array (#169555)
davidstone Dec 2, 2025
6984f94
[MemProf] Require x86 for memprof-pgho.cpp test (#170321)
melver Dec 2, 2025
c691020
[NFC] [clang-tidy] Fix potential SA issues. (#170289)
zahiraam Dec 2, 2025
4ff3d1c
[profcheck] update exclude list (#170316)
mtrofin Dec 2, 2025
669683a
clang/AMDGPU: Add missing __opencl_c_read_write_images feature macro …
arsenm Dec 2, 2025
5681c71
Revert "[flang] implement show_descriptor intrinsic, a non-standard e…
Meinersbur Dec 2, 2025
2209d33
[CIR][X86] Add support for kunpck builtins (#168757)
ahmednoursphinx Dec 2, 2025
5c552c5
[lldb] Fix GetExpressionPath for vector registers (#169210)
da-viper Dec 2, 2025
9063416
[OpenMP][clang] Remove metadata checks in amdgcn_weak_alias.c (#170326)
Jason-VanBeusekom Dec 2, 2025
2ad7174
[LSR] Insert the transformed IV increment in the user block (#169515)
john-brawn-arm Dec 2, 2025
c037128
[ARM] Introduce intrinsics for MVE minnm/maxnm under strict-fp. (#169…
davemgreen Dec 2, 2025
1e6476d
[LV] Add predicated store sinking tests requiring further noalias checks
fhahn Dec 2, 2025
5fa103a
[clang][Docs] Move debug info flags into groups (#169942)
jryans Dec 2, 2025
a8ef3c8
[mlir][vector][test] Fix comment in test (nfc) (#170336)
banach-space Dec 2, 2025
ea00593
[MLIR][XeGPU][Quickfix] Disable block count in propagation (#170304)
akroviakov Dec 2, 2025
e0f3302
[ValueTracking] Support scalable vector splats in computeKnownFPClass…
dtcxzyw Dec 2, 2025
ac66ae4
[bazel] feat: update bazel lldb for llvm:support dep (#170344)
kevinwkt Dec 2, 2025
5e5937c
[LLDB] Add SBFrameExtensions Tests (#169236)
ahmednoursphinx Dec 2, 2025
ef49c92
[NFC][LLVM] Namespace cleanup in ScalarEvolution (#166620)
jurahul Dec 2, 2025
2c38632
LTO: Remove unused TargetLibraryInfo include (#170340)
arsenm Dec 2, 2025
4587fe6
[lld] Fix typo in lld manpage, nfc (#170299)
serge-sans-paille Dec 2, 2025
23a22d0
[SROA] Unify the names of new instructions created in SROA. (#167917)
rastogishubham Dec 2, 2025
e0db7f3
[WebAssembly] Optimize away mask of 63 for sra and srl( zext (and i32…
badumbatish Dec 2, 2025
1a3709c
[SPIRV] Error for zero-length arrays if not a shader (#169732)
sarnex Dec 2, 2025
41a53c0
[lldb/Target] Add BorrowedStackFrame and make StackFrame methods virt…
medismailben Dec 2, 2025
2183846
[AMDGPU] Fix AGPR_32 reg assign for mfma scale ops (#168964)
hjagasiaAMD Dec 2, 2025
5c3c002
[NFC] Refactor TargetLowering::getTgtMemIntrinsic to take CallBase pa…
ro-i Dec 2, 2025
697b1be
[AMDGPU][NFC] Put gfx125x common features into 12_50_Common (#170338)
changpeng Dec 2, 2025
73979c1
[mlir][amdgpu] Lower amdgpu.make_dma_base (#169817)
amd-eochoalo Dec 2, 2025
6e262aa
[gn build] Port 41a53c0a23ee
llvmgnsyncbot Dec 2, 2025
879dddf
[AArch64] Add tests for umulh. NFC
davemgreen Dec 2, 2025
c50802c
Reland "[lldb] Introduce ScriptedFrameProvider for real threads (#161…
medismailben Dec 2, 2025
3f2e3e6
[mlir][AMDGPU][NFC] Fix overlapping masked load refinements (#159805)
krzysz00 Dec 2, 2025
fae64ad
[lldb] Handle deref of register and implicit locations (#169419)
dmpots Dec 2, 2025
6dd639e
[CIR][OpenACC] Implement 'routine' lowering + seq clause (#170207)
erichkeane Dec 2, 2025
b50a590
[acc][flang] Add genLoad and genStore to PointerLikeType (#170348)
razvanlupusoru Dec 2, 2025
49a9787
[SCEV] Regenerate a subset of auto updated tests
preames Dec 2, 2025
ca3de05
[CIR][NFC] Fix a release build warning (#170359)
andykaylor Dec 2, 2025
0bb987f
Revert "[CUDA][HIP] Fix CTAD for host/device constructors (#168711)"
yxsamliu Dec 2, 2025
c910d82
[OpenACC][CIR] Add worker/vector clause lowering for Routine (#170358)
erichkeane Dec 2, 2025
c77fe58
[bazel] update bazel build for PluginScriptedProcess (#170364)
kevinwkt Dec 2, 2025
12ae727
[CIR] Upstream support for builtin_constant_p (#170354)
andykaylor Dec 2, 2025
d97746c
[libc++] Fix the rest of __gnu_cxx::hash_XXX copy construction (#160525)
asmok-g Dec 2, 2025
139ebfa
[Bazel] Fix `--warn-backrefs` errors in `Analysis` target (#170357)
jmacnak Dec 2, 2025
f0e1254
[LV] Use forced cost once for whole interleave group in legacy costmo…
fhahn Dec 2, 2025
4006df9
[OpenACC][CIR] Implement 'nohost' lowering. (#170369)
erichkeane Dec 2, 2025
bd5fa63
[VPlan] Remove duplicated computeCost call (NFC).
fhahn Dec 2, 2025
d3256d9
[flang][cuda] Add alignment to shared memory operation (#170372)
clementval Dec 2, 2025
41519b3
[SCEV] Add UDiv canonicalization tests with nested AddRecs.
fhahn Dec 2, 2025
fff45dd
[lldb-dap] Follow the spec more closely on 'initialize' arguments. (#…
ashgti Dec 2, 2025
434127b
[HLSL] Static resources (#166880)
hekota Dec 2, 2025
9885aed
[flang][cuda] Add address cast for src and dst in TMA operations (#17…
clementval Dec 2, 2025
6773883
merge main into amd-staging
ronlieb Dec 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ExpandModularHeadersPPCallbacks : public PPCallbacks {
std::unique_ptr<Preprocessor> PP;
bool EnteredMainFile = false;
bool StartedLexing = false;
Token CurrentToken;
Token CurrentToken = Token();
};

} // namespace tooling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void FloatLoopCounterCheck::registerMatchers(MatchFinder *Finder) {

void FloatLoopCounterCheck::check(const MatchFinder::MatchResult &Result) {
const auto *FS = Result.Nodes.getNodeAs<ForStmt>("for");
assert(FS && "FS should not be null");

diag(FS->getInc()->getBeginLoc(), "loop induction expression should not have "
"floating-point type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void ProBoundsAvoidUncheckedContainerAccessCheck::check(
}
} else if (const auto *MCE = dyn_cast<CXXMemberCallExpr>(MatchedExpr)) {
// Case: a.operator[](i) or a->operator[](i)
const auto *Callee = dyn_cast<MemberExpr>(MCE->getCallee());
const auto *Callee = cast<MemberExpr>(MCE->getCallee());

if (FixMode == At) {
// Cases: a.operator[](i) => a.at(i) and a->operator[](i) => a->at(i)
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/AST/ASTConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace clang {
class VarDecl;
class FunctionDecl;
class ImportDecl;
class OpenACCRoutineDecl;

/// ASTConsumer - This is an abstract interface that should be implemented by
/// clients that read ASTs. This abstraction layer allows the client to be
Expand Down Expand Up @@ -116,6 +117,11 @@ class ASTConsumer {
// variable has been instantiated.
virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}

/// Callback to handle the end-of-translation unit attachment of OpenACC
/// routine declaration information.
virtual void HandleOpenACCRoutineReference(const FunctionDecl *FD,
const OpenACCRoutineDecl *RD) {}

/// Callback involved at the end of a translation unit to
/// notify the consumer that a vtable for the given C++ class is
/// required.
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Basic/arm_mve.td
Original file line number Diff line number Diff line change
Expand Up @@ -783,15 +783,15 @@ let params = T.Unsigned in {
}
let params = T.Float in {
def vminnmq: Intrinsic<Vector, (args Vector:$a, Vector:$b),
(IRIntBase<"minnum", [Vector]> $a, $b)>;
(fminnm $a, $b)>;
def vmaxnmq: Intrinsic<Vector, (args Vector:$a, Vector:$b),
(IRIntBase<"maxnum", [Vector]> $a, $b)>;
(fmaxnm $a, $b)>;
def vminnmaq: Intrinsic<Vector, (args Vector:$a, Vector:$b),
(IRIntBase<"minnum", [Vector]>
(fminnm
(IRIntBase<"fabs", [Vector]> $a),
(IRIntBase<"fabs", [Vector]> $b))>;
def vmaxnmaq: Intrinsic<Vector, (args Vector:$a, Vector:$b),
(IRIntBase<"maxnum", [Vector]>
(fmaxnm
(IRIntBase<"fabs", [Vector]> $a),
(IRIntBase<"fabs", [Vector]> $b))>;
}
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/arm_mve_defs.td
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ def fsub: strictFPAlt<fsub_node,
IRInt<"vsub", [Vector]>>;
def fmul: strictFPAlt<fmul_node,
IRInt<"vmul", [Vector]>>;
def fminnm : strictFPAlt<IRIntBase<"minnum", [Vector]>,
IRInt<"vminnm", [Vector]>>;
def fmaxnm : strictFPAlt<IRIntBase<"maxnum", [Vector]>,
IRInt<"vmaxnm", [Vector]>>;

// -----------------------------------------------------------------------------
// Convenience lists of parameter types. 'T' is just a container record, so you
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/CIR/CIRGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class CIRGenerator : public clang::ASTConsumer {
void HandleTagDeclDefinition(clang::TagDecl *d) override;
void HandleTagDeclRequiredDefinition(const clang::TagDecl *D) override;
void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *D) override;
void
HandleOpenACCRoutineReference(const clang::FunctionDecl *FD,
const clang::OpenACCRoutineDecl *RD) override;
void CompleteTentativeDefinition(clang::VarDecl *d) override;
void HandleVTable(clang::CXXRecordDecl *rd) override;

Expand Down
29 changes: 29 additions & 0 deletions clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,35 @@ def CIR_SwitchOp : CIR_Op<"switch", [
let hasLLVMLowering = false;
}

//===----------------------------------------------------------------------===//
// IsConstantOp
//===----------------------------------------------------------------------===//

def CIR_IsConstantOp : CIR_Op<"is_constant", [Pure]> {
let summary = "Test for manifest compile-time constant";
let description = [{
Returns `true` if the argument is known to be a manifest compile-time
constant otherwise returns `false`. If the argument is a constant expression
which refers to a global (the address of which _is_ a constant, but not
manifest during the compile), then the intrinsic evaluates to `false`.

This is used to represent `__builtin_constant_p` in cases where the argument
isn't known to be constant during initial translation of the source code but
might be proven to be constant after later optimizations.

Example:
```
%1 = cir.is_constant %2 : !s32i -> !cir.bool
```
}];
let arguments = (ins CIR_AnyType:$val);
let results = (outs CIR_BoolType:$result);

let assemblyFormat = [{
$val `:` qualified(type($val)) `->` qualified(type($result)) attr-dict
}];
}

//===----------------------------------------------------------------------===//
// SwitchFlatOp
//===----------------------------------------------------------------------===//
Expand Down
36 changes: 21 additions & 15 deletions clang/include/clang/Options/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -4870,25 +4870,25 @@ def ggdb3 : Flag<["-"], "ggdb3">, Group<ggdbN_Group>;
def glldb : Flag<["-"], "glldb">, Group<gTune_Group>;
def gsce : Flag<["-"], "gsce">, Group<gTune_Group>;
def gdbx : Flag<["-"], "gdbx">, Group<gTune_Group>;
// Equivalent to our default dwarf version. Forces usual dwarf emission when
// Equivalent to our default DWARF version. Forces usual DWARF emission when
// CodeView is enabled.
def gdwarf : Flag<["-"], "gdwarf">, Group<g_Group>,
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
HelpText<"Generate source-level debug information with the default dwarf version">;
HelpText<"Generate source-level debug information with the default DWARF version">;

let Visibility = [ClangOption, FlangOption] in {
def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 2">;
HelpText<"Generate source-level debug information with DWARF version 2">;
def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 3">;
HelpText<"Generate source-level debug information with DWARF version 3">;
def gdwarf_4 : Flag<["-"], "gdwarf-4">, Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 4">;
HelpText<"Generate source-level debug information with DWARF version 4">;
def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 5">;
HelpText<"Generate source-level debug information with DWARF version 5">;
def gdwarf_6
: Flag<["-"], "gdwarf-6">,
Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 6">;
HelpText<"Generate source-level debug information with DWARF version 6">;
}
def gdwarf64 : Flag<["-"], "gdwarf64">, Group<g_Group>,
Visibility<[ClangOption, CC1Option, CC1AsOption]>,
Expand All @@ -4915,25 +4915,28 @@ def gno_heterogeneous_dwarf : Flag<["-"], "gno-heterogeneous-dwarf">,
HelpText<"Disable DWARF extensions for heterogeneous debugging">,
Alias<gheterogeneous_dwarf_EQ>, AliasArgs<["disabled"]>;

def gcodeview : Flag<["-"], "gcodeview">,
def gcodeview : Flag<["-"], "gcodeview">, Group<g_Group>,
HelpText<"Generate CodeView debug information">,
Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
MarshallingInfoFlag<CodeGenOpts<"EmitCodeView">>;
defm codeview_ghash : BoolOption<"g", "codeview-ghash",
CodeGenOpts<"CodeViewGHash">, DefaultFalse,
PosFlag<SetTrue, [], [ClangOption, CC1Option],
"Emit type record hashes in a .debug$H section">,
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>;
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
Group<g_flags_Group>;
defm codeview_command_line : BoolOption<"g", "codeview-command-line",
CodeGenOpts<"CodeViewCommandLine">, DefaultTrue,
PosFlag<SetTrue, [], [ClangOption], "Emit compiler path and command line into CodeView debug information">,
NegFlag<SetFalse, [], [ClangOption], "Don't emit compiler path and command line into CodeView debug information">,
BothFlags<[], [ClangOption, CLOption, DXCOption, CC1Option]>>;
BothFlags<[], [ClangOption, CLOption, DXCOption, CC1Option]>>,
Group<g_flags_Group>;
defm inline_line_tables : BoolGOption<"inline-line-tables",
CodeGenOpts<"NoInlineLineTables">, DefaultFalse,
NegFlag<SetTrue, [], [ClangOption, CC1Option],
"Don't emit inline line tables.">,
PosFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>;
PosFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
Group<g_flags_Group>;

def gfull : Flag<["-"], "gfull">, Group<g_Group>;
def gused : Flag<["-"], "gused">, Group<g_Group>;
Expand All @@ -4958,7 +4961,8 @@ defm strict_dwarf : BoolOption<"g", "strict-dwarf",
defm omit_unreferenced_methods : BoolGOption<"omit-unreferenced-methods",
CodeGenOpts<"DebugOmitUnreferencedMethods">, DefaultFalse,
NegFlag<SetFalse>,
PosFlag<SetTrue, [], [CC1Option]>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>;
PosFlag<SetTrue, [], [CC1Option]>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
Group<g_flags_Group>;
defm column_info : BoolOption<"g", "column-info",
CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
NegFlag<SetFalse, [], [ClangOption, CC1Option]>,
Expand Down Expand Up @@ -5027,6 +5031,7 @@ defm structor_decl_linkage_names
"Attach linkage names to C++ constructor/destructor "
"declarations in DWARF.">,
BothFlags<[], [ClangOption, CLOption, CC1Option]>>,
Group<g_flags_Group>,
DocBrief<[{On some ABIs (e.g., Itanium), constructors and destructors may have multiple variants. Historically, when generating DWARF, Clang did not attach ``DW_AT_linkage_name`` to structor DIEs because there were multiple possible manglings (depending on the structor variant) that could be used. With ``-gstructor-decl-linkage-names``, for ABIs with structor variants, we attach a "unified" mangled name to structor declarations DIEs which debuggers can use to look up all the definitions for a structor declaration. E.g., a "unified" mangled name ``_ZN3FooC4Ev`` may have multiple definitions associated with it such as ``_ZN3FooC1Ev`` and ``_ZN3FooC2Ev``.

Enabling this flag results in a better interactive debugging experience (both GDB and LLDB have support for understanding these "unified" linkage names). However, it comes with a significant increase in debug-info size (particularly the `.debug_str` section). As an escape hatch, users can disable this feature using ``-gno-structor-decl-linkage-names``.}]>;
Expand All @@ -5035,7 +5040,8 @@ defm key_instructions : BoolGOption<"key-instructions",
NegFlag<SetFalse>, PosFlag<SetTrue, [], [],
"Enable Key Instructions, which reduces the jumpiness of debug stepping in optimized C/C++ code"
" in some debuggers. DWARF only.">,
BothFlags<[], [ClangOption, CLOption, CC1Option]>>;
BothFlags<[], [ClangOption, CLOption, CC1Option]>>,
Group<g_flags_Group>;
def headerpad__max__install__names : Joined<["-"], "headerpad_max_install_names">;
def help : Flag<["-", "--"], "help">,
Visibility<[ClangOption, CC1Option, CC1AsOption,
Expand Down Expand Up @@ -8690,7 +8696,7 @@ def main_file_name : Separate<["-"], "main-file-name">,
Visibility<[CC1Option, CC1AsOption]>,
MarshallingInfoString<CodeGenOpts<"MainFileName">>;
def split_dwarf_output : Separate<["-"], "split-dwarf-output">,
HelpText<"File name to use for split dwarf debug info output">,
HelpText<"File name to use for split DWARF debug info output">,
Visibility<[CC1Option, CC1AsOption, FC1Option]>,
MarshallingInfoString<CodeGenOpts<"SplitDwarfOutput">>;

Expand Down Expand Up @@ -8724,7 +8730,7 @@ def dependent_lib : Joined<["--"], "dependent-lib=">,
MarshallingInfoStringVector<CodeGenOpts<"DependentLibraries">>;

def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
HelpText<"Name of the split dwarf debug info file to encode in the object file">,
HelpText<"Name of the split DWARF debug info file to encode in the object file">,
MarshallingInfoString<CodeGenOpts<"SplitDwarfFile">>;

} // let Visibility = [CC1Option, FC1Option]
Expand Down
9 changes: 9 additions & 0 deletions clang/include/clang/Sema/SemaOpenACC.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ class Scope;
class SemaOpenACC : public SemaBase {
public:
using DeclGroupPtrTy = OpaquePtr<DeclGroupRef>;
using RoutineRefListTy = std::pair<FunctionDecl *, OpenACCRoutineDecl *>;

private:
// We save a list of routine clauses that refer to a different function(that
// is, routine-with-a-name) so that we can do the emission at the 'end'. We
// have to do this, since functions can be emitted before they are referenced,
// and the OpenACCRoutineDecl isn't necessarily emitted, as it might be in a
// function/etc. So we do these emits at the end of the TU.
llvm::SmallVector<RoutineRefListTy> RoutineRefList;

struct ComputeConstructInfo {
/// Which type of compute construct we are inside of, which we can use to
/// determine whether we should add loops to the above collection. We can
Expand Down Expand Up @@ -752,6 +760,7 @@ class SemaOpenACC : public SemaBase {
};

SemaOpenACC(Sema &S);
void ActOnEndOfTranslationUnit(TranslationUnitDecl *TU);

// Called when we encounter a 'while' statement, before looking at its 'body'.
void ActOnWhileStmt(SourceLocation WhileLoc);
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Basic/Targets/AMDGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
Opts["cl_amd_media_ops"] = true;
Opts["cl_amd_media_ops2"] = true;

// FIXME: Check subtarget for image support.
Opts["__opencl_c_images"] = true;
Opts["__opencl_c_3d_image_writes"] = true;
Opts["__opencl_c_read_write_images"] = true;
Opts["cl_khr_3d_image_writes"] = true;
Opts["__opencl_c_program_scope_global_variables"] = true;
Opts["__opencl_c_atomic_order_seq_cst"] = true;
Expand Down
39 changes: 39 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,45 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
return emitCall(e->getCallee()->getType(), CIRGenCallee::forDirect(fnOp), e,
returnValue);
}

case Builtin::BI__builtin_constant_p: {
mlir::Type resultType = convertType(e->getType());

const Expr *arg = e->getArg(0);
QualType argType = arg->getType();
// FIXME: The allowance for Obj-C pointers and block pointers is historical
// and likely a mistake.
if (!argType->isIntegralOrEnumerationType() && !argType->isFloatingType() &&
!argType->isObjCObjectPointerType() && !argType->isBlockPointerType()) {
// Per the GCC documentation, only numeric constants are recognized after
// inlining.
return RValue::get(
builder.getConstInt(getLoc(e->getSourceRange()),
mlir::cast<cir::IntType>(resultType), 0));
}

if (arg->HasSideEffects(getContext())) {
// The argument is unevaluated, so be conservative if it might have
// side-effects.
return RValue::get(
builder.getConstInt(getLoc(e->getSourceRange()),
mlir::cast<cir::IntType>(resultType), 0));
}

mlir::Value argValue = emitScalarExpr(arg);
if (argType->isObjCObjectPointerType()) {
cgm.errorNYI(e->getSourceRange(),
"__builtin_constant_p: Obj-C object pointer");
return {};
}
argValue = builder.createBitcast(argValue, convertType(argType));

mlir::Value result = cir::IsConstantOp::create(
builder, getLoc(e->getSourceRange()), argValue);
// IsConstantOp returns a bool, but __builtin_constant_p returns an int.
result = builder.createBoolToInt(result, resultType);
return RValue::get(result);
}
case Builtin::BI__builtin_dynamic_object_size:
case Builtin::BI__builtin_object_size: {
unsigned type =
Expand Down
51 changes: 47 additions & 4 deletions clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,44 @@ static mlir::Value emitX86MaskAddLogic(CIRGenBuilderTy &builder,
return builder.createBitcast(resVec, ops[0].getType());
}

static mlir::Value emitX86MaskUnpack(CIRGenBuilderTy &builder,
mlir::Location loc,
const std::string &intrinsicName,
SmallVectorImpl<mlir::Value> &ops) {
unsigned numElems = cast<cir::IntType>(ops[0].getType()).getWidth();

// Convert both operands to mask vectors.
mlir::Value lhs = getMaskVecValue(builder, loc, ops[0], numElems);
mlir::Value rhs = getMaskVecValue(builder, loc, ops[1], numElems);

mlir::Type i32Ty = builder.getSInt32Ty();

// Create indices for extracting the first half of each vector.
SmallVector<mlir::Attribute, 32> halfIndices;
for (auto i : llvm::seq<unsigned>(0, numElems / 2))
halfIndices.push_back(cir::IntAttr::get(i32Ty, i));

// Extract first half of each vector. This gives better codegen than
// doing it in a single shuffle.
mlir::Value lhsHalf = builder.createVecShuffle(loc, lhs, lhs, halfIndices);
mlir::Value rhsHalf = builder.createVecShuffle(loc, rhs, rhs, halfIndices);

// Create indices for concatenating the vectors.
// NOTE: Operands are swapped to match the intrinsic definition.
// After the half extraction, both vectors have numElems/2 elements.
// In createVecShuffle(rhsHalf, lhsHalf, indices), indices [0..numElems/2-1]
// select from rhsHalf, and indices [numElems/2..numElems-1] select from
// lhsHalf.
SmallVector<mlir::Attribute, 64> concatIndices;
for (auto i : llvm::seq<unsigned>(0, numElems))
concatIndices.push_back(cir::IntAttr::get(i32Ty, i));

// Concat the vectors (RHS first, then LHS).
mlir::Value res =
builder.createVecShuffle(loc, rhsHalf, lhsHalf, concatIndices);
return builder.createBitcast(res, ops[0].getType());
}

static mlir::Value emitX86MaskLogic(CIRGenBuilderTy &builder,
mlir::Location loc,
cir::BinOpKind binOpKind,
Expand Down Expand Up @@ -257,7 +295,15 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
return emitVecInsert(builder, getLoc(expr->getExprLoc()), ops[0], ops[1],
ops[2]);
}

case X86::BI__builtin_ia32_kunpckhi:
return emitX86MaskUnpack(builder, getLoc(expr->getExprLoc()),
"x86.avx512.kunpackb", ops);
case X86::BI__builtin_ia32_kunpcksi:
return emitX86MaskUnpack(builder, getLoc(expr->getExprLoc()),
"x86.avx512.kunpackw", ops);
case X86::BI__builtin_ia32_kunpckdi:
return emitX86MaskUnpack(builder, getLoc(expr->getExprLoc()),
"x86.avx512.kunpackd", ops);
case X86::BI_mm_setcsr:
case X86::BI__builtin_ia32_ldmxcsr: {
mlir::Location loc = getLoc(expr->getExprLoc());
Expand Down Expand Up @@ -947,9 +993,6 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
getMaskVecValue(builder, getLoc(expr->getExprLoc()), ops[0], numElts);
return builder.createBitcast(resVec, ops[0].getType());
}
case X86::BI__builtin_ia32_kunpckdi:
case X86::BI__builtin_ia32_kunpcksi:
case X86::BI__builtin_ia32_kunpckhi:
case X86::BI__builtin_ia32_sqrtsh_round_mask:
case X86::BI__builtin_ia32_sqrtsd_round_mask:
case X86::BI__builtin_ia32_sqrtss_round_mask:
Expand Down
Loading