Skip to content

Commit

Permalink
ABI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxSciurorum authored and neboat committed Aug 23, 2020
1 parent 5735821 commit a0dbbd8
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 158 deletions.
34 changes: 26 additions & 8 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4524,16 +4524,34 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (!Triple.isOSLinux() && !Triple.isOSFreeBSD() && !Triple.isMacOSX())
D.Diag(diag::err_drv_cilk_unsupported);

/* JFC: Is it possible to confuse with with -fno-opencilk? */
bool OpenCilk = Args.hasArgNoClaim(options::OPT_fopencilk);
bool Cheetah = false;

if (Arg *TapirRuntime = Args.getLastArgNoClaim(options::OPT_ftapir_EQ)) {
// Cheetah runtime is x86 only.
if (TapirRuntime->getValue() == StringRef("cheetah")) {
if (Triple.getArch() != llvm::Triple::x86_64)
D.Diag(diag::err_drv_cilk_unsupported);
}
// OpenCilk will additionally support 64 bit ARM.
Cheetah = TapirRuntime->getValue() == StringRef("cheetah");
if (TapirRuntime->getValue() == StringRef("opencilk")) {
if (Triple.getArch() != llvm::Triple::x86_64 && !Triple.isAArch64())
D.Diag(diag::err_drv_cilk_unsupported);
OpenCilk = true;
}
}

if (Cheetah && Triple.getArch() != llvm::Triple::x86_64) {
D.Diag(diag::err_drv_cilk_unsupported);
}
if (OpenCilk) {
switch (Triple.getArch()) {
case llvm::Triple::x86:
case llvm::Triple::x86_64:
case llvm::Triple::arm:
case llvm::Triple::armeb:
break;
case llvm::Triple::aarch64:
case llvm::Triple::aarch64_be:
case llvm::Triple::aarch64_32:
/* ARMv8 is waiting on builtin setjmp/longjmp. */
default:
D.Diag(diag::err_drv_cilk_unsupported);
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//===- CilkRABI.h - Interface to the CilkR runtime system ------*- C++ -*--===//
//===- OpenilkABI.h - Interface to the OpenCilk runtime system ---*- C++ -*--=//
//
// 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 implements the CilkR ABI to converts Tapir instructions to calls
// into the CilkR runtime system.
// This file implements the OpenCilk ABI to converts Tapir instructions to calls
// into the OpenCilk runtime system.
//
//===----------------------------------------------------------------------===//
#ifndef CILK_RABI_H_
#define CILK_RABI_H_
#ifndef OPEN_CILK_ABI_H_
#define OPEN_CILK_ABI_H_

#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/IRBuilder.h"
Expand All @@ -21,21 +21,23 @@ namespace llvm {
class Value;
class TapirLoopInfo;

class CilkRABI : public TapirTarget {
class OpenCilkABI : public TapirTarget {
ValueToValueMapTy DetachCtxToStackFrame;
SmallPtrSet<CallBase *, 8> CallsToInline;

// Cilk RTS data types
StructType *StackFrameTy = nullptr;
StructType *WorkerTy = nullptr;
short StackFrameFieldFlags = -1;
short StackFrameFieldParent = -1;
short StackFrameFieldWorker = -1;
short StackFrameFieldContext = -1;
short StackFrameFieldMXCSR = -1;
short StackFrameFieldFPCSR = -1;
short WorkerFieldTail = 0;
short WorkerFieldFrame = 7;
signed char StackFrameFieldFlags = -1;
signed char StackFrameFieldParent = -1;
signed char StackFrameFieldWorker = -1;
signed char StackFrameFieldContext = -1;
signed char StackFrameFieldMXCSR = -1;
signed char StackFrameFieldMagic = -1;
signed char WorkerFieldTail = 0;
signed char WorkerFieldFrame = 7;

uint32_t FrameMagic = 0;

// Opaque Cilk RTS functions
FunctionCallee CilkRTSLeaveFrame = nullptr;
Expand All @@ -48,9 +50,6 @@ class CilkRABI : public TapirTarget {
FunctionCallee CilkRTSCheckExceptionRaise = nullptr;
FunctionCallee CilkRTSCleanupFiber = nullptr;

const int FrameVersion;
int FrameVersionFlag() const { return FrameVersion << 24; }

// Accessors for opaque Cilk RTS functions
FunctionCallee Get__cilkrts_leave_frame();
// FunctionCallee Get__cilkrts_rethrow();
Expand Down Expand Up @@ -91,8 +90,8 @@ class CilkRABI : public TapirTarget {
void MarkSpawner(Function &F);

public:
CilkRABI(Module &M, bool OpenCilk);
~CilkRABI() { DetachCtxToStackFrame.clear(); }
OpenCilkABI(Module &M);
~OpenCilkABI() { DetachCtxToStackFrame.clear(); }
Value *lowerGrainsizeCall(CallInst *GrainsizeCall) override final;
void lowerSync(SyncInst &SI) override final;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Tapir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
add_llvm_library(LLVMTapirOpts
CilkABI.cpp
CilkRABI.cpp
CilkRTSCilkFor.cpp
CudaABI.cpp
DRFScopedNoAliasAA.cpp
LoopSpawningTI.cpp
LoopStripMine.cpp
LoopStripMinePass.cpp
LoweringUtils.cpp
OpenCilkABI.cpp
OpenMPABI.cpp
Outline.cpp
QthreadsABI.cpp
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Transforms/Tapir/LoweringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/Timer.h"
#include "llvm/Transforms/Tapir/CilkABI.h"
#include "llvm/Transforms/Tapir/CilkRABI.h"
#include "llvm/Transforms/Tapir/CudaABI.h"
#include "llvm/Transforms/Tapir/OpenCilkABI.h"
#include "llvm/Transforms/Tapir/OpenMPABI.h"
#include "llvm/Transforms/Tapir/Outline.h"
#include "llvm/Transforms/Tapir/QthreadsABI.h"
Expand All @@ -44,13 +44,11 @@ TapirTarget *llvm::getTapirTargetFromID(Module &M, TapirTargetID ID) {
return new SerialABI(M);
case TapirTargetID::Cilk:
return new CilkABI(M);
case TapirTargetID::CilkR:
case TapirTargetID::Cheetah:
return new CilkRABI(M, false);
case TapirTargetID::Cuda:
return new CudaABI(M);
case TapirTargetID::Cheetah:
case TapirTargetID::OpenCilk:
return new CilkRABI(M, true);
return new OpenCilkABI(M);
case TapirTargetID::OpenMP:
return new OpenMPABI(M);
case TapirTargetID::Qthreads:
Expand Down
Loading

0 comments on commit a0dbbd8

Please sign in to comment.