Skip to content

Commit

Permalink
Merged master:82f6ae5433c into amd-gfx:f07e6001b81
Browse files Browse the repository at this point in the history
Local branch amd-gfx f07e600 Merged master:cd04e8349bd into amd-gfx:12ed18ff8c4
Remote branch master 82f6ae5 [clang-change-namespace] Change file pattern to be an anchored regex
  • Loading branch information
Sw authored and Sw committed Dec 4, 2019
2 parents f07e600 + 82f6ae5 commit 936fb7d
Show file tree
Hide file tree
Showing 23 changed files with 800 additions and 171 deletions.
8 changes: 8 additions & 0 deletions clang-tools-extra/clangd/clients/clangd-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"activationEvents": [
"onLanguage:c",
"onLanguage:cpp",
"onLanguage:cuda",
"onLanguage:objective-c",
"onLanguage:objective-cpp",
"onCommand:clangd-vscode.activate"
Expand Down Expand Up @@ -64,6 +65,13 @@
"**/MSVC/*/include/**"
],
"firstLine": "^/[/*].*-\\*-\\s*C\\+\\+\\s*-\\*-.*"
},
{
"id": "cuda",
"extensions": [
".cu",
".cuh"
]
}
],
"configuration": {
Expand Down
18 changes: 6 additions & 12 deletions clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,15 @@ export function activate(context: vscode.ExtensionContext) {
}
const serverOptions: vscodelc.ServerOptions = clangd;

// Note that CUDA ('.cu') files are special. When opening files of all other
// extensions, VSCode would load clangd automatically. This is achieved by
// having a corresponding 'onLanguage:...' activation event in package.json.
// However, VSCode does not have CUDA as a supported language yet, so we
// cannot add a corresponding activationEvent for CUDA files and clangd will
// *not* load itself automatically on '.cu' files.
const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
const clientOptions: vscodelc.LanguageClientOptions = {
// Register the server for c-family and cuda files.
documentSelector: [
{ scheme: 'file', language: 'c' },
{ scheme: 'file', language: 'cpp' },
// cuda is not supported by vscode, but our extension does.
{ scheme: 'file', language: 'cuda' },
{ scheme: 'file', language: 'objective-c'},
{ scheme: 'file', language: 'objective-cpp'},
{ scheme: 'file', pattern: cudaFilePattern },
{ scheme: 'file', language: 'objective-cpp'}
],
synchronize: !syncFileEvents ? undefined : {
// FIXME: send sync file events when clangd provides implemenatations.
Expand All @@ -111,10 +105,10 @@ export function activate(context: vscode.ExtensionContext) {
serverOptions, clientOptions);
if (getConfig<boolean>('semanticHighlighting')) {
const semanticHighlightingFeature =
new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
context);
new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
context);
context.subscriptions.push(
vscode.Disposable.from(semanticHighlightingFeature));
vscode.Disposable.from(semanticHighlightingFeature));
clangdClient.registerFeature(semanticHighlightingFeature);
}
console.log('Clang Language Server is now active!');
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/test/clang-change-namespace/macro.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: cp %S/macro.cpp %T/macro.cpp
// RUN: echo "#define USING using na::nc::X" > %T/macro.h
//
// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp" --i %T/macro.cpp --
// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp$" --i %T/macro.cpp --
// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-HEADER %s
//
Expand Down
10 changes: 10 additions & 0 deletions clang/include/clang/Basic/arm_mve.td
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def vornq: Intrinsic<Vector, (args Vector:$a, Vector:$b), (or $a, (not $b))>;
def vorrq: Intrinsic<Vector, (args Vector:$a, Vector:$b), (or $a, $b)>;
def vsubq: Intrinsic<Vector, (args Vector:$a, Vector:$b), (sub $a, $b)>;
def vmulq: Intrinsic<Vector, (args Vector:$a, Vector:$b), (mul $a, $b)>;
def vmulhq: Intrinsic<Vector, (args Vector:$a, Vector:$b),
(IRInt<"vmulh", [Vector]> $a, $b)>;
def vrmulhq: Intrinsic<Vector, (args Vector:$a, Vector:$b),
(IRInt<"vrmulh", [Vector]> $a, $b)>;
}

let params = T.Float in {
Expand Down Expand Up @@ -113,6 +117,12 @@ def vminq_m: Intrinsic<
def vmaxq_m: Intrinsic<
Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
(IRInt<"max_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
def vmulhq_m: Intrinsic<
Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
(IRInt<"mulh_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
def vrmulhq_m: Intrinsic<
Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
(IRInt<"rmulh_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
}

// Predicated intrinsics - Float types only
Expand Down
7 changes: 7 additions & 0 deletions clang/include/clang/Tooling/CompilationDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <memory>
#include <string>
#include <utility>
Expand Down Expand Up @@ -219,6 +220,12 @@ std::unique_ptr<CompilationDatabase>
std::unique_ptr<CompilationDatabase>
inferTargetAndDriverMode(std::unique_ptr<CompilationDatabase> Base);

/// Returns a wrapped CompilationDatabase that will expand all rsp(response)
/// files on commandline returned by underlying database.
std::unique_ptr<CompilationDatabase>
expandResponseFiles(std::unique_ptr<CompilationDatabase> Base,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS);

} // namespace tooling
} // namespace clang

Expand Down
19 changes: 19 additions & 0 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6128,7 +6128,26 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
if ((getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) &&
Var->hasGlobalStorage())
ImplAS = LangAS::opencl_global;
// If the original type from a decayed type is an array type and that array
// type has no address space yet, deduce it now.
if (auto DT = dyn_cast<DecayedType>(Type)) {
auto OrigTy = DT->getOriginalType();
if (!OrigTy.getQualifiers().hasAddressSpace() && OrigTy->isArrayType()) {
// Add the address space to the original array type and then propagate
// that to the element type through `getAsArrayType`.
OrigTy = Context.getAddrSpaceQualType(OrigTy, ImplAS);
OrigTy = QualType(Context.getAsArrayType(OrigTy), 0);
// Re-generate the decayed type.
Type = Context.getDecayedType(OrigTy);
}
}
Type = Context.getAddrSpaceQualType(Type, ImplAS);
// Apply any qualifiers (including address space) from the array type to
// the element type. This implements C99 6.7.3p8: "If the specification of
// an array type includes any type qualifiers, the element type is so
// qualified, not the array type."
if (Type->isArrayType())
Type = QualType(Context.getAsArrayType(Type), 0);
Decl->setType(Type);
}
}
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Tooling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_clang_library(clangTooling
CommonOptionsParser.cpp
CompilationDatabase.cpp
Execution.cpp
ExpandResponseFilesCompilationDatabase.cpp
FileMatchTrie.cpp
FixIt.cpp
GuessTargetAndModeCompilationDatabase.cpp
Expand Down
88 changes: 88 additions & 0 deletions clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//===- ExpandResponseFileCompilationDataBase.cpp --------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/StringSaver.h"

namespace clang {
namespace tooling {
namespace {

class ExpandResponseFilesDatabase : public CompilationDatabase {
public:
ExpandResponseFilesDatabase(
std::unique_ptr<CompilationDatabase> Base,
llvm::cl::TokenizerCallback Tokenizer,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
: Base(std::move(Base)), Tokenizer(Tokenizer), FS(std::move(FS)) {
assert(this->Base != nullptr);
assert(this->Tokenizer != nullptr);
assert(this->FS != nullptr);
}

std::vector<std::string> getAllFiles() const override {
return Base->getAllFiles();
}

std::vector<CompileCommand>
getCompileCommands(StringRef FilePath) const override {
return expand(Base->getCompileCommands(FilePath));
}

std::vector<CompileCommand> getAllCompileCommands() const override {
return expand(Base->getAllCompileCommands());
}

private:
std::vector<CompileCommand> expand(std::vector<CompileCommand> Cmds) const {
for (auto &Cmd : Cmds) {
bool SeenRSPFile = false;
llvm::SmallVector<const char *, 20> Argv;
Argv.reserve(Cmd.CommandLine.size());
for (auto &Arg : Cmd.CommandLine) {
Argv.push_back(Arg.c_str());
SeenRSPFile |= Arg.front() == '@';
}
if (!SeenRSPFile)
continue;
llvm::BumpPtrAllocator Alloc;
llvm::StringSaver Saver(Alloc);
llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS,
llvm::StringRef(Cmd.Directory));
Cmd.CommandLine.assign(Argv.begin(), Argv.end());
}
return Cmds;
}

private:
std::unique_ptr<CompilationDatabase> Base;
llvm::cl::TokenizerCallback Tokenizer;
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
};

} // namespace

std::unique_ptr<CompilationDatabase>
expandResponseFiles(std::unique_ptr<CompilationDatabase> Base,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
auto Tokenizer = llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows()
? llvm::cl::TokenizeWindowsCommandLine
: llvm::cl::TokenizeGNUCommandLine;
return std::make_unique<ExpandResponseFilesDatabase>(
std::move(Base), Tokenizer, std::move(FS));
}

} // namespace tooling
} // namespace clang
4 changes: 3 additions & 1 deletion clang/lib/Tooling/JSONCompilationDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
Expand Down Expand Up @@ -168,7 +169,8 @@ class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
auto Base = JSONCompilationDatabase::loadFromFile(
JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
return Base ? inferTargetAndDriverMode(
inferMissingCompileCommands(std::move(Base)))
inferMissingCompileCommands(expandResponseFiles(
std::move(Base), llvm::vfs::getRealFileSystem())))
: nullptr;
}
};
Expand Down
95 changes: 95 additions & 0 deletions clang/test/CodeGen/arm-mve-intrinsics/vmulhq.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s

#include <arm_mve.h>

// CHECK-LABEL: @test_vmulhq_u8(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.arm.mve.vmulh.v16i8(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]])
// CHECK-NEXT: ret <16 x i8> [[TMP0]]
//
uint8x16_t test_vmulhq_u8(uint8x16_t a, uint8x16_t b)
{
#ifdef POLYMORPHIC
return vmulhq(a, b);
#else /* POLYMORPHIC */
return vmulhq_u8(a, b);
#endif /* POLYMORPHIC */
}

// CHECK-LABEL: @test_vmulhq_s16(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = call <8 x i16> @llvm.arm.mve.vmulh.v8i16(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]])
// CHECK-NEXT: ret <8 x i16> [[TMP0]]
//
int16x8_t test_vmulhq_s16(int16x8_t a, int16x8_t b)
{
#ifdef POLYMORPHIC
return vmulhq(a, b);
#else /* POLYMORPHIC */
return vmulhq_s16(a, b);
#endif /* POLYMORPHIC */
}

// CHECK-LABEL: @test_vmulhq_u32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = call <4 x i32> @llvm.arm.mve.vmulh.v4i32(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]])
// CHECK-NEXT: ret <4 x i32> [[TMP0]]
//
uint32x4_t test_vmulhq_u32(uint32x4_t a, uint32x4_t b)
{
#ifdef POLYMORPHIC
return vmulhq(a, b);
#else /* POLYMORPHIC */
return vmulhq_u32(a, b);
#endif /* POLYMORPHIC */
}

// CHECK-LABEL: @test_vmulhq_m_s8(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
// CHECK-NEXT: [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
// CHECK-NEXT: [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.mulh.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
// CHECK-NEXT: ret <16 x i8> [[TMP2]]
//
int8x16_t test_vmulhq_m_s8(int8x16_t inactive, int8x16_t a, int8x16_t b, mve_pred16_t p)
{
#ifdef POLYMORPHIC
return vmulhq_m(inactive, a, b, p);
#else /* POLYMORPHIC */
return vmulhq_m_s8(inactive, a, b, p);
#endif /* POLYMORPHIC */
}

// CHECK-LABEL: @test_vmulhq_m_u16(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
// CHECK-NEXT: [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
// CHECK-NEXT: [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.mulh.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], <8 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
// CHECK-NEXT: ret <8 x i16> [[TMP2]]
//
uint16x8_t test_vmulhq_m_u16(uint16x8_t inactive, uint16x8_t a, uint16x8_t b, mve_pred16_t p)
{
#ifdef POLYMORPHIC
return vmulhq_m(inactive, a, b, p);
#else /* POLYMORPHIC */
return vmulhq_m_u16(inactive, a, b, p);
#endif /* POLYMORPHIC */
}

// CHECK-LABEL: @test_vmulhq_m_s32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
// CHECK-NEXT: [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
// CHECK-NEXT: [[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.mulh.predicated.v4i32.v4i1(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i1> [[TMP1]], <4 x i32> [[INACTIVE:%.*]])
// CHECK-NEXT: ret <4 x i32> [[TMP2]]
//
int32x4_t test_vmulhq_m_s32(int32x4_t inactive, int32x4_t a, int32x4_t b, mve_pred16_t p)
{
#ifdef POLYMORPHIC
return vmulhq_m(inactive, a, b, p);
#else /* POLYMORPHIC */
return vmulhq_m_s32(inactive, a, b, p);
#endif /* POLYMORPHIC */
}
Loading

0 comments on commit 936fb7d

Please sign in to comment.