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) {
22 if ((MI->getOpcode() != NVPTX::LD_i32_avar) &&
23 (MI->getOpcode() != NVPTX::LD_i64_avar))
25 if (MI->getOperand(2).isImm() == false)
27 if (MI->getOperand(2).getImm() != NVPTX::PTXLdStInstCode::PARAM)
32 #define DATA_MASK 0x7f
34 #define MORE_BYTES 0x80
36 static int encode_leb128(uint64_t val, int *nbytes, char *space, int splen) {
38 char *end = space + splen;
61 uint64_t encode_leb128(const char *str) {
69 for (unsigned i = 0, e = strlen(str); i != e; ++i)
70 temp64.a[i] = str[e - 1 - i];
75 int retval = encode_leb128(temp64.x, &nbytes, encoded, 16);
78 assert(retval == 0 && "Encoding to leb128 failed");
81 "Cannot support register names with leb128 encoding > 8 bytes");
84 for (int i = 0; i < nbytes; ++i)
85 temp64.a[i] = encoded[i];
90 } // end namespace llvm