|
15 | 15 | #include "CIRGenCXXABI.h"
|
16 | 16 | #include "CIRGenCstEmitter.h"
|
17 | 17 | #include "CIRGenFunction.h"
|
| 18 | +#include "CIRGenOpenMPRuntime.h" |
18 | 19 | #include "CIRGenTypes.h"
|
19 | 20 | #include "CIRGenValue.h"
|
20 | 21 | #include "TargetInfo.h"
|
@@ -103,7 +104,7 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &context,
|
103 | 104 | codeGenOpts(CGO),
|
104 | 105 | theModule{mlir::ModuleOp::create(builder.getUnknownLoc())}, Diags(Diags),
|
105 | 106 | target(astCtx.getTargetInfo()), ABI(createCXXABI(*this)), genTypes{*this},
|
106 |
| - VTables{*this} { |
| 107 | + VTables{*this}, openMPRuntime(new CIRGenOpenMPRuntime(*this)) { |
107 | 108 |
|
108 | 109 | // Initialize CIR signed integer types cache.
|
109 | 110 | SInt8Ty =
|
@@ -613,8 +614,8 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef MangledName, mlir::Type Ty,
|
613 | 614 | !D->hasAttr<clang::DLLExportAttr>())
|
614 | 615 | assert(!UnimplementedFeature::setDLLStorageClass() && "NYI");
|
615 | 616 |
|
616 |
| - if (getLangOpts().OpenMP && !getLangOpts().OpenMPSimd && D) |
617 |
| - assert(0 && "not implemented"); |
| 617 | + if (langOpts.OpenMP && !langOpts.OpenMPSimd && D) |
| 618 | + getOpenMPRuntime().registerTargetGlobalVariable(D, Entry); |
618 | 619 |
|
619 | 620 | // TODO(cir): check TargetAS matches Entry address space
|
620 | 621 | if (Entry.getSymType() == Ty &&
|
@@ -685,7 +686,8 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef MangledName, mlir::Type Ty,
|
685 | 686 |
|
686 | 687 | // Handle things which are present even on external declarations.
|
687 | 688 | if (D) {
|
688 |
| - // TODO[OpenMP]: Check and handle target globals. |
| 689 | + if (langOpts.OpenMP && !langOpts.OpenMPSimd && D) |
| 690 | + getOpenMPRuntime().registerTargetGlobalVariable(D, Entry); |
689 | 691 |
|
690 | 692 | // FIXME: This code is overly simple and should be merged with other global
|
691 | 693 | // handling.
|
@@ -2299,17 +2301,18 @@ void CIRGenModule::buildGlobalDecl(clang::GlobalDecl &D) {
|
2299 | 2301 | }
|
2300 | 2302 |
|
2301 | 2303 | // If this is OpenMP, check if it is legal to emit this global normally.
|
2302 |
| - if (getLangOpts().OpenMP) { |
2303 |
| - // TODO[OpenMP]: Emit target globals. |
2304 |
| - } |
| 2304 | + if (getLangOpts().OpenMP && openMPRuntime && |
| 2305 | + openMPRuntime->emitTargetGlobal(D)) |
| 2306 | + return; |
2305 | 2307 |
|
2306 | 2308 | // Otherwise, emit the definition and move on to the next one.
|
2307 | 2309 | buildGlobalDefinition(D, Op);
|
2308 | 2310 | }
|
2309 | 2311 |
|
2310 | 2312 | void CIRGenModule::buildDeferred(unsigned recursionLimit) {
|
2311 | 2313 | // Emit deferred declare target declarations
|
2312 |
| - // TODO[OpenMP]: Emit deferred target declarations. |
| 2314 | + if (getLangOpts().OpenMP && !getLangOpts().OpenMPSimd) |
| 2315 | + getOpenMPRuntime().emitDeferredTargetDecls(); |
2313 | 2316 |
|
2314 | 2317 | // Emit code for any potentially referenced deferred decls. Since a previously
|
2315 | 2318 | // unused static decl may become used during the generation of code for a
|
|
0 commit comments