1 //===-- NVPTXutil.cpp - Functions exported to CodeGen --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the functions that can be used in CodeGen.
12 //===----------------------------------------------------------------------===//
14 #include "NVPTXutil.h"
21 bool isParamLoad(const MachineInstr *MI)
23 if ((MI->getOpcode() != NVPTX::LD_i32_avar) &&
24 (MI->getOpcode() != NVPTX::LD_i64_avar))
26 if (MI->getOperand(2).isImm() == false)
28 if (MI->getOperand(2).getImm() != NVPTX::PTXLdStInstCode::PARAM)
33 #define DATA_MASK 0x7f
35 #define MORE_BYTES 0x80
37 static int encode_leb128(uint64_t val, int *nbytes,
38 char *space, int splen)
41 char *end = space + splen;
64 uint64_t encode_leb128(const char *str)
66 union { uint64_t x; char a[8]; } temp64;
70 for (unsigned i=0,e=strlen(str); i!=e; ++i)
71 temp64.a[i] = str[e-1-i];
76 int retval = encode_leb128(temp64.x, &nbytes, encoded, 16);
80 "Encoding to leb128 failed");
83 "Cannot support register names with leb128 encoding > 8 bytes");
86 for (int i=0; i<nbytes; ++i)
87 temp64.a[i] = encoded[i];
92 } // end namespace llvm