Skip to content

Commit e82fcda

Browse files
authored
[Coroutines] Move util headers to include/llvm (#111599)
Plugin libraries that use coroutines can do so right now, however, to provide their own ABI they need to be able to use various headers, some of which such are required (such as the ABI header). This change exposes the coro utils and required headers by moving them to include/llvm/Transforms/Coroutines. My experience with our out-of-tree plugin ABI has been that at least these headers are needed. The headers moved are: * ABI.h (ABI object) * CoroInstr.h (helpers) * Coroshape.h (Shape object) * MaterializationUtils.h (helpers) * SpillingUtils.h (helpers) * SuspendCrossingInfo.h (analysis) This has no code changes other than those required to move the headers and these are: * include guard name changes * include path changes * minor clang-format induced changes * removal of LLVM_LIBRARY_VISIBILITY
1 parent 1cfe5b8 commit e82fcda

File tree

16 files changed

+85
-83
lines changed

16 files changed

+85
-83
lines changed

llvm/lib/Transforms/Coroutines/ABI.h renamed to llvm/include/llvm/Transforms/Coroutines/ABI.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
// ABI enum and ABI class are used by the Coroutine passes when lowering.
1313
//===----------------------------------------------------------------------===//
1414

15-
#ifndef LIB_TRANSFORMS_COROUTINES_ABI_H
16-
#define LIB_TRANSFORMS_COROUTINES_ABI_H
15+
#ifndef LLVM_TRANSFORMS_COROUTINES_ABI_H
16+
#define LLVM_TRANSFORMS_COROUTINES_ABI_H
1717

18-
#include "CoroShape.h"
19-
#include "SuspendCrossingInfo.h"
2018
#include "llvm/Analysis/TargetTransformInfo.h"
19+
#include "llvm/Transforms/Coroutines/CoroShape.h"
20+
#include "llvm/Transforms/Coroutines/MaterializationUtils.h"
21+
#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
2122

2223
namespace llvm {
2324

@@ -30,7 +31,7 @@ namespace coro {
3031
// ABI operations. The ABIs (e.g. Switch, Async, Retcon{Once}) are the common
3132
// ABIs.
3233

33-
class LLVM_LIBRARY_VISIBILITY BaseABI {
34+
class BaseABI {
3435
public:
3536
BaseABI(Function &F, coro::Shape &S,
3637
std::function<bool(Instruction &)> IsMaterializable)
@@ -56,7 +57,7 @@ class LLVM_LIBRARY_VISIBILITY BaseABI {
5657
std::function<bool(Instruction &I)> IsMaterializable;
5758
};
5859

59-
class LLVM_LIBRARY_VISIBILITY SwitchABI : public BaseABI {
60+
class SwitchABI : public BaseABI {
6061
public:
6162
SwitchABI(Function &F, coro::Shape &S,
6263
std::function<bool(Instruction &)> IsMaterializable)
@@ -69,7 +70,7 @@ class LLVM_LIBRARY_VISIBILITY SwitchABI : public BaseABI {
6970
TargetTransformInfo &TTI) override;
7071
};
7172

72-
class LLVM_LIBRARY_VISIBILITY AsyncABI : public BaseABI {
73+
class AsyncABI : public BaseABI {
7374
public:
7475
AsyncABI(Function &F, coro::Shape &S,
7576
std::function<bool(Instruction &)> IsMaterializable)
@@ -82,7 +83,7 @@ class LLVM_LIBRARY_VISIBILITY AsyncABI : public BaseABI {
8283
TargetTransformInfo &TTI) override;
8384
};
8485

85-
class LLVM_LIBRARY_VISIBILITY AnyRetconABI : public BaseABI {
86+
class AnyRetconABI : public BaseABI {
8687
public:
8788
AnyRetconABI(Function &F, coro::Shape &S,
8889
std::function<bool(Instruction &)> IsMaterializable)

llvm/lib/Transforms/Coroutines/CoroInstr.h renamed to llvm/include/llvm/Transforms/Coroutines/CoroInstr.h

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
// the Coroutine library.
2323
//===----------------------------------------------------------------------===//
2424

25-
#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
26-
#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
25+
#ifndef LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
26+
#define LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
2727

2828
#include "llvm/IR/GlobalVariable.h"
2929
#include "llvm/IR/IntrinsicInst.h"
@@ -32,7 +32,7 @@
3232
namespace llvm {
3333

3434
/// This class represents the llvm.coro.subfn.addr instruction.
35-
class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst {
35+
class CoroSubFnInst : public IntrinsicInst {
3636
enum { FrameArg, IndexArg };
3737

3838
public:
@@ -67,7 +67,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst {
6767
};
6868

6969
/// This represents the llvm.coro.alloc instruction.
70-
class LLVM_LIBRARY_VISIBILITY CoroAllocInst : public IntrinsicInst {
70+
class CoroAllocInst : public IntrinsicInst {
7171
public:
7272
// Methods to support type inquiry through isa, cast, and dyn_cast:
7373
static bool classof(const IntrinsicInst *I) {
@@ -82,7 +82,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocInst : public IntrinsicInst {
8282
// FIXME: add callback metadata
8383
// FIXME: make a proper IntrinisicInst. Currently this is not possible,
8484
// because llvm.coro.await.suspend.* can be invoked.
85-
class LLVM_LIBRARY_VISIBILITY CoroAwaitSuspendInst : public CallBase {
85+
class CoroAwaitSuspendInst : public CallBase {
8686
enum { AwaiterArg, FrameArg, WrapperArg };
8787

8888
public:
@@ -112,7 +112,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAwaitSuspendInst : public CallBase {
112112
};
113113

114114
/// This represents a common base class for llvm.coro.id instructions.
115-
class LLVM_LIBRARY_VISIBILITY AnyCoroIdInst : public IntrinsicInst {
115+
class AnyCoroIdInst : public IntrinsicInst {
116116
public:
117117
CoroAllocInst *getCoroAlloc() {
118118
for (User *U : users())
@@ -143,7 +143,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdInst : public IntrinsicInst {
143143
};
144144

145145
/// This represents the llvm.coro.id instruction.
146-
class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
146+
class CoroIdInst : public AnyCoroIdInst {
147147
enum { AlignArg, PromiseArg, CoroutineArg, InfoArg };
148148

149149
public:
@@ -232,7 +232,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
232232

233233
/// This represents either the llvm.coro.id.retcon or
234234
/// llvm.coro.id.retcon.once instruction.
235-
class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
235+
class AnyCoroIdRetconInst : public AnyCoroIdInst {
236236
enum { SizeArg, AlignArg, StorageArg, PrototypeArg, AllocArg, DeallocArg };
237237

238238
public:
@@ -246,9 +246,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
246246
return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
247247
}
248248

249-
Value *getStorage() const {
250-
return getArgOperand(StorageArg);
251-
}
249+
Value *getStorage() const { return getArgOperand(StorageArg); }
252250

253251
/// Return the prototype for the continuation function. The type,
254252
/// attributes, and calling convention of the continuation function(s)
@@ -270,17 +268,16 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
270268
// Methods to support type inquiry through isa, cast, and dyn_cast:
271269
static bool classof(const IntrinsicInst *I) {
272270
auto ID = I->getIntrinsicID();
273-
return ID == Intrinsic::coro_id_retcon
274-
|| ID == Intrinsic::coro_id_retcon_once;
271+
return ID == Intrinsic::coro_id_retcon ||
272+
ID == Intrinsic::coro_id_retcon_once;
275273
}
276274
static bool classof(const Value *V) {
277275
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
278276
}
279277
};
280278

281279
/// This represents the llvm.coro.id.retcon instruction.
282-
class LLVM_LIBRARY_VISIBILITY CoroIdRetconInst
283-
: public AnyCoroIdRetconInst {
280+
class CoroIdRetconInst : public AnyCoroIdRetconInst {
284281
public:
285282
// Methods to support type inquiry through isa, cast, and dyn_cast:
286283
static bool classof(const IntrinsicInst *I) {
@@ -292,8 +289,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdRetconInst
292289
};
293290

294291
/// This represents the llvm.coro.id.retcon.once instruction.
295-
class LLVM_LIBRARY_VISIBILITY CoroIdRetconOnceInst
296-
: public AnyCoroIdRetconInst {
292+
class CoroIdRetconOnceInst : public AnyCoroIdRetconInst {
297293
public:
298294
// Methods to support type inquiry through isa, cast, and dyn_cast:
299295
static bool classof(const IntrinsicInst *I) {
@@ -305,7 +301,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdRetconOnceInst
305301
};
306302

307303
/// This represents the llvm.coro.id.async instruction.
308-
class LLVM_LIBRARY_VISIBILITY CoroIdAsyncInst : public AnyCoroIdInst {
304+
class CoroIdAsyncInst : public AnyCoroIdInst {
309305
enum { SizeArg, AlignArg, StorageArg, AsyncFuncPtrArg };
310306

311307
public:
@@ -356,7 +352,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdAsyncInst : public AnyCoroIdInst {
356352
};
357353

358354
/// This represents the llvm.coro.context.alloc instruction.
359-
class LLVM_LIBRARY_VISIBILITY CoroAsyncContextAllocInst : public IntrinsicInst {
355+
class CoroAsyncContextAllocInst : public IntrinsicInst {
360356
enum { AsyncFuncPtrArg };
361357

362358
public:
@@ -375,8 +371,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncContextAllocInst : public IntrinsicInst {
375371
};
376372

377373
/// This represents the llvm.coro.context.dealloc instruction.
378-
class LLVM_LIBRARY_VISIBILITY CoroAsyncContextDeallocInst
379-
: public IntrinsicInst {
374+
class CoroAsyncContextDeallocInst : public IntrinsicInst {
380375
enum { AsyncContextArg };
381376

382377
public:
@@ -396,7 +391,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncContextDeallocInst
396391
/// This represents the llvm.coro.async.resume instruction.
397392
/// During lowering this is replaced by the resume function of a suspend point
398393
/// (the continuation function).
399-
class LLVM_LIBRARY_VISIBILITY CoroAsyncResumeInst : public IntrinsicInst {
394+
class CoroAsyncResumeInst : public IntrinsicInst {
400395
public:
401396
// Methods to support type inquiry through isa, cast, and dyn_cast:
402397
static bool classof(const IntrinsicInst *I) {
@@ -408,7 +403,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncResumeInst : public IntrinsicInst {
408403
};
409404

410405
/// This represents the llvm.coro.async.size.replace instruction.
411-
class LLVM_LIBRARY_VISIBILITY CoroAsyncSizeReplace : public IntrinsicInst {
406+
class CoroAsyncSizeReplace : public IntrinsicInst {
412407
public:
413408
// Methods to support type inquiry through isa, cast, and dyn_cast:
414409
static bool classof(const IntrinsicInst *I) {
@@ -420,7 +415,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncSizeReplace : public IntrinsicInst {
420415
};
421416

422417
/// This represents the llvm.coro.frame instruction.
423-
class LLVM_LIBRARY_VISIBILITY CoroFrameInst : public IntrinsicInst {
418+
class CoroFrameInst : public IntrinsicInst {
424419
public:
425420
// Methods to support type inquiry through isa, cast, and dyn_cast:
426421
static bool classof(const IntrinsicInst *I) {
@@ -432,7 +427,7 @@ class LLVM_LIBRARY_VISIBILITY CoroFrameInst : public IntrinsicInst {
432427
};
433428

434429
/// This represents the llvm.coro.free instruction.
435-
class LLVM_LIBRARY_VISIBILITY CoroFreeInst : public IntrinsicInst {
430+
class CoroFreeInst : public IntrinsicInst {
436431
enum { IdArg, FrameArg };
437432

438433
public:
@@ -447,8 +442,8 @@ class LLVM_LIBRARY_VISIBILITY CoroFreeInst : public IntrinsicInst {
447442
}
448443
};
449444

450-
/// This class represents the llvm.coro.begin instruction.
451-
class LLVM_LIBRARY_VISIBILITY CoroBeginInst : public IntrinsicInst {
445+
/// This class represents the llvm.coro.begin instructions.
446+
class CoroBeginInst : public IntrinsicInst {
452447
enum { IdArg, MemArg };
453448

454449
public:
@@ -468,7 +463,7 @@ class LLVM_LIBRARY_VISIBILITY CoroBeginInst : public IntrinsicInst {
468463
};
469464

470465
/// This represents the llvm.coro.save instruction.
471-
class LLVM_LIBRARY_VISIBILITY CoroSaveInst : public IntrinsicInst {
466+
class CoroSaveInst : public IntrinsicInst {
472467
public:
473468
// Methods to support type inquiry through isa, cast, and dyn_cast:
474469
static bool classof(const IntrinsicInst *I) {
@@ -480,7 +475,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSaveInst : public IntrinsicInst {
480475
};
481476

482477
/// This represents the llvm.coro.promise instruction.
483-
class LLVM_LIBRARY_VISIBILITY CoroPromiseInst : public IntrinsicInst {
478+
class CoroPromiseInst : public IntrinsicInst {
484479
enum { FrameArg, AlignArg, FromArg };
485480

486481
public:
@@ -505,7 +500,7 @@ class LLVM_LIBRARY_VISIBILITY CoroPromiseInst : public IntrinsicInst {
505500
}
506501
};
507502

508-
class LLVM_LIBRARY_VISIBILITY AnyCoroSuspendInst : public IntrinsicInst {
503+
class AnyCoroSuspendInst : public IntrinsicInst {
509504
public:
510505
CoroSaveInst *getCoroSave() const;
511506

@@ -521,7 +516,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroSuspendInst : public IntrinsicInst {
521516
};
522517

523518
/// This represents the llvm.coro.suspend instruction.
524-
class LLVM_LIBRARY_VISIBILITY CoroSuspendInst : public AnyCoroSuspendInst {
519+
class CoroSuspendInst : public AnyCoroSuspendInst {
525520
enum { SaveArg, FinalArg };
526521

527522
public:
@@ -553,7 +548,7 @@ inline CoroSaveInst *AnyCoroSuspendInst::getCoroSave() const {
553548
}
554549

555550
/// This represents the llvm.coro.suspend.async instruction.
556-
class LLVM_LIBRARY_VISIBILITY CoroSuspendAsyncInst : public AnyCoroSuspendInst {
551+
class CoroSuspendAsyncInst : public AnyCoroSuspendInst {
557552
public:
558553
enum {
559554
StorageArgNoArg,
@@ -594,7 +589,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSuspendAsyncInst : public AnyCoroSuspendInst {
594589
};
595590

596591
/// This represents the llvm.coro.suspend.retcon instruction.
597-
class LLVM_LIBRARY_VISIBILITY CoroSuspendRetconInst : public AnyCoroSuspendInst {
592+
class CoroSuspendRetconInst : public AnyCoroSuspendInst {
598593
public:
599594
op_iterator value_begin() { return arg_begin(); }
600595
const_op_iterator value_begin() const { return arg_begin(); }
@@ -619,7 +614,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSuspendRetconInst : public AnyCoroSuspendInst
619614
};
620615

621616
/// This represents the llvm.coro.size instruction.
622-
class LLVM_LIBRARY_VISIBILITY CoroSizeInst : public IntrinsicInst {
617+
class CoroSizeInst : public IntrinsicInst {
623618
public:
624619
// Methods to support type inquiry through isa, cast, and dyn_cast:
625620
static bool classof(const IntrinsicInst *I) {
@@ -631,7 +626,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSizeInst : public IntrinsicInst {
631626
};
632627

633628
/// This represents the llvm.coro.align instruction.
634-
class LLVM_LIBRARY_VISIBILITY CoroAlignInst : public IntrinsicInst {
629+
class CoroAlignInst : public IntrinsicInst {
635630
public:
636631
// Methods to support type inquiry through isa, cast, and dyn_cast:
637632
static bool classof(const IntrinsicInst *I) {
@@ -643,7 +638,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAlignInst : public IntrinsicInst {
643638
};
644639

645640
/// This represents the llvm.end.results instruction.
646-
class LLVM_LIBRARY_VISIBILITY CoroEndResults : public IntrinsicInst {
641+
class CoroEndResults : public IntrinsicInst {
647642
public:
648643
op_iterator retval_begin() { return arg_begin(); }
649644
const_op_iterator retval_begin() const { return arg_begin(); }
@@ -671,7 +666,7 @@ class LLVM_LIBRARY_VISIBILITY CoroEndResults : public IntrinsicInst {
671666
}
672667
};
673668

674-
class LLVM_LIBRARY_VISIBILITY AnyCoroEndInst : public IntrinsicInst {
669+
class AnyCoroEndInst : public IntrinsicInst {
675670
enum { FrameArg, UnwindArg, TokenArg };
676671

677672
public:
@@ -700,7 +695,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroEndInst : public IntrinsicInst {
700695
};
701696

702697
/// This represents the llvm.coro.end instruction.
703-
class LLVM_LIBRARY_VISIBILITY CoroEndInst : public AnyCoroEndInst {
698+
class CoroEndInst : public AnyCoroEndInst {
704699
public:
705700
// Methods to support type inquiry through isa, cast, and dyn_cast:
706701
static bool classof(const IntrinsicInst *I) {
@@ -712,7 +707,7 @@ class LLVM_LIBRARY_VISIBILITY CoroEndInst : public AnyCoroEndInst {
712707
};
713708

714709
/// This represents the llvm.coro.end instruction.
715-
class LLVM_LIBRARY_VISIBILITY CoroAsyncEndInst : public AnyCoroEndInst {
710+
class CoroAsyncEndInst : public AnyCoroEndInst {
716711
enum { FrameArg, UnwindArg, MustTailCallFuncArg };
717712

718713
public:
@@ -736,12 +731,11 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncEndInst : public AnyCoroEndInst {
736731
};
737732

738733
/// This represents the llvm.coro.alloca.alloc instruction.
739-
class LLVM_LIBRARY_VISIBILITY CoroAllocaAllocInst : public IntrinsicInst {
734+
class CoroAllocaAllocInst : public IntrinsicInst {
740735
enum { SizeArg, AlignArg };
736+
741737
public:
742-
Value *getSize() const {
743-
return getArgOperand(SizeArg);
744-
}
738+
Value *getSize() const { return getArgOperand(SizeArg); }
745739
Align getAlignment() const {
746740
return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
747741
}
@@ -756,8 +750,9 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaAllocInst : public IntrinsicInst {
756750
};
757751

758752
/// This represents the llvm.coro.alloca.get instruction.
759-
class LLVM_LIBRARY_VISIBILITY CoroAllocaGetInst : public IntrinsicInst {
753+
class CoroAllocaGetInst : public IntrinsicInst {
760754
enum { AllocArg };
755+
761756
public:
762757
CoroAllocaAllocInst *getAlloc() const {
763758
return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
@@ -773,8 +768,9 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaGetInst : public IntrinsicInst {
773768
};
774769

775770
/// This represents the llvm.coro.alloca.free instruction.
776-
class LLVM_LIBRARY_VISIBILITY CoroAllocaFreeInst : public IntrinsicInst {
771+
class CoroAllocaFreeInst : public IntrinsicInst {
777772
enum { AllocArg };
773+
778774
public:
779775
CoroAllocaAllocInst *getAlloc() const {
780776
return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
@@ -791,4 +787,4 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaFreeInst : public IntrinsicInst {
791787

792788
} // End namespace llvm.
793789

794-
#endif
790+
#endif // LLVM_TRANSFORMS_COROUTINES_COROINSTR_H

0 commit comments

Comments
 (0)