[PATCH] D16784: [OpenMP] Reorganize code to allow specialized code generation for different devices.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 22:19:09 PST 2016


ABataev added inline comments.

================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:340-341
@@ +339,4 @@
+  case llvm::Triple::nvptx64:
+    assert(CGM.getLangOpts().OpenMPIsDevice &&
+           "OpenMP NVPTX is only prepared to deal with device code.");
+    return createCGOpenMPRuntimeNVPTX(CGM);
----------------
I think it is better to reorganize this code like that:
```
switch (CGM.getTarget().getTriple().getArch()) {
  case llvm::Triple::nvptx:
  case llvm::Triple::nvptx64:
    assert(CGM.getLangOpts().OpenMPIsDevice &&
           "OpenMP NVPTX is only prepared to deal with device code.");
    return new CGOpenMPRuntimeNVPTX(CGM);
  default:
    break;
}
return new CGOpenMPRuntime(CGM);
```

================
Comment at: lib/CodeGen/CGOpenMPRuntime.h:552-555
@@ -551,2 +551,6 @@
 
+  /// \brief Create specialized OpenMP runtime code generation class for NVPTX
+  /// targets.
+  static CGOpenMPRuntime *createCGOpenMPRuntimeNVPTX(CodeGenModule &CGM);
+
 public:
----------------
Do you really need this function? Currently, I don't see a point in adding this platform-specific thing to (mostly) common interface


http://reviews.llvm.org/D16784





More information about the cfe-commits mailing list