[llvm-commits] [llvm] r157369 - in /llvm/trunk/lib/Target/NVPTX: NVPTXAsmPrinter.cpp NVPTXISelLowering.cpp
Craig Topper
craig.topper at gmail.com
Wed May 23 21:22:06 PDT 2012
Author: ctopper
Date: Wed May 23 23:22:05 2012
New Revision: 157369
URL: http://llvm.org/viewvc/llvm-project?rev=157369&view=rev
Log:
Mark a couple arrays as static and const. Use array_lengthof instead of sizeof/sizeof.
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=157369&r1=157368&r2=157369&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Wed May 23 23:22:05 2012
@@ -490,7 +490,7 @@
void NVPTXAsmPrinter::printVecModifiedImmediate(const MachineOperand &MO,
const char *Modifier,
raw_ostream &O) {
-char vecelem[] = {'0', '1', '2', '3', '0', '1', '2', '3'};
+ static const char vecelem[] = {'0', '1', '2', '3', '0', '1', '2', '3'};
int Imm = (int)MO.getImm();
if(0 == strcmp(Modifier, "vecelem"))
O << "_" << vecelem[Imm];
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=157369&r1=157368&r2=157369&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp Wed May 23 23:22:05 2012
@@ -887,10 +887,10 @@
// Check to see if the kernel argument is image*_t or sampler_t
bool llvm::isImageOrSamplerVal(const Value *arg, const Module *context) {
- const char *specialTypes[] = {
- "struct._image2d_t",
- "struct._image3d_t",
- "struct._sampler_t"
+ static const char *const specialTypes[] = {
+ "struct._image2d_t",
+ "struct._image3d_t",
+ "struct._sampler_t"
};
const Type *Ty = arg->getType();
@@ -905,7 +905,7 @@
const StructType *STy = dyn_cast<StructType>(PTy->getElementType());
const std::string TypeName = STy ? STy->getName() : "";
- for (int i=0, e=sizeof(specialTypes)/sizeof(specialTypes[0]); i!=e; ++i)
+ for (int i = 0, e = array_lengthof(specialTypes); i != e; ++i)
if (TypeName == specialTypes[i])
return true;
More information about the llvm-commits
mailing list