Deleted Added
full compact
NVPTXutil.cpp (239462) NVPTXutil.cpp (249423)
1//===-- NVPTXutil.cpp - Functions exported to CodeGen --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 4 unchanged lines hidden (view full) ---

13
14#include "NVPTXutil.h"
15#include "NVPTX.h"
16
17using namespace llvm;
18
19namespace llvm {
20
1//===-- NVPTXutil.cpp - Functions exported to CodeGen --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 4 unchanged lines hidden (view full) ---

13
14#include "NVPTXutil.h"
15#include "NVPTX.h"
16
17using namespace llvm;
18
19namespace llvm {
20
21bool isParamLoad(const MachineInstr *MI)
22{
21bool isParamLoad(const MachineInstr *MI) {
23 if ((MI->getOpcode() != NVPTX::LD_i32_avar) &&
24 (MI->getOpcode() != NVPTX::LD_i64_avar))
25 return false;
26 if (MI->getOperand(2).isImm() == false)
27 return false;
28 if (MI->getOperand(2).getImm() != NVPTX::PTXLdStInstCode::PARAM)
29 return false;
30 return true;
31}
32
22 if ((MI->getOpcode() != NVPTX::LD_i32_avar) &&
23 (MI->getOpcode() != NVPTX::LD_i64_avar))
24 return false;
25 if (MI->getOperand(2).isImm() == false)
26 return false;
27 if (MI->getOperand(2).getImm() != NVPTX::PTXLdStInstCode::PARAM)
28 return false;
29 return true;
30}
31
33#define DATA_MASK 0x7f
34#define DIGIT_WIDTH 7
35#define MORE_BYTES 0x80
32#define DATA_MASK 0x7f
33#define DIGIT_WIDTH 7
34#define MORE_BYTES 0x80
36
35
37static int encode_leb128(uint64_t val, int *nbytes,
38 char *space, int splen)
39{
36static int encode_leb128(uint64_t val, int *nbytes, char *space, int splen) {
40 char *a;
41 char *end = space + splen;
42
43 a = space;
44 do {
45 unsigned char uc;
46
47 if (a >= end)

--- 8 unchanged lines hidden (view full) ---

56 *nbytes = a - space;
57 return 0;
58}
59
60#undef DATA_MASK
61#undef DIGIT_WIDTH
62#undef MORE_BYTES
63
37 char *a;
38 char *end = space + splen;
39
40 a = space;
41 do {
42 unsigned char uc;
43
44 if (a >= end)

--- 8 unchanged lines hidden (view full) ---

53 *nbytes = a - space;
54 return 0;
55}
56
57#undef DATA_MASK
58#undef DIGIT_WIDTH
59#undef MORE_BYTES
60
64uint64_t encode_leb128(const char *str)
65{
66 union { uint64_t x; char a[8]; } temp64;
61uint64_t encode_leb128(const char *str) {
62 union {
63 uint64_t x;
64 char a[8];
65 } temp64;
67
68 temp64.x = 0;
69
66
67 temp64.x = 0;
68
70 for (unsigned i=0,e=strlen(str); i!=e; ++i)
71 temp64.a[i] = str[e-1-i];
69 for (unsigned i = 0, e = strlen(str); i != e; ++i)
70 temp64.a[i] = str[e - 1 - i];
72
73 char encoded[16];
74 int nbytes;
75
76 int retval = encode_leb128(temp64.x, &nbytes, encoded, 16);
77
71
72 char encoded[16];
73 int nbytes;
74
75 int retval = encode_leb128(temp64.x, &nbytes, encoded, 16);
76
78 (void)retval;
79 assert(retval == 0 &&
80 "Encoding to leb128 failed");
77 (void) retval;
78 assert(retval == 0 && "Encoding to leb128 failed");
81
82 assert(nbytes <= 8 &&
83 "Cannot support register names with leb128 encoding > 8 bytes");
84
85 temp64.x = 0;
79
80 assert(nbytes <= 8 &&
81 "Cannot support register names with leb128 encoding > 8 bytes");
82
83 temp64.x = 0;
86 for (int i=0; i<nbytes; ++i)
84 for (int i = 0; i < nbytes; ++i)
87 temp64.a[i] = encoded[i];
88
89 return temp64.x;
90}
91
92} // end namespace llvm
85 temp64.a[i] = encoded[i];
86
87 return temp64.x;
88}
89
90} // end namespace llvm