in my pass I inspect the penultimate instruction from every basic block in runOnFunction(). I am interested in ICMP instructions only.
if(BB->size()>1)
if(last->getPrevNode())
{
previous = last->getPrevNode();
ok=1;
}
I want to get the operands of previous, which is of type Instruction*. Due tests based on getNumOperands, ICMP has 2 (as normal).
if ( ok && ((previous->getNumOperands())>=2) )
errs()<<"\nTTTTT "<<previous->getOperand(0)->getName()<<" | "
<<previous->getOperand(0)->getValueName()<<" | "
<<previous->getOperand(0)->getValueID()<<" | "
<<previous->getOperand(0)->getNumUses()<<" TTTTT\n";
The results with getOperand(1) are similar.
The output is:
*PREVIOUS: store i32 %conv15, i32* %i, align 4
TTTTT conv15 | 0x9b69090 | 59 | 1 TTTTT
...
*PREVIOUS: store i32 %inc13, i32* %i, align 4
TTTTT inc13 | 0x9b76478 | 30 | 1 TTTTT
...
*PREVIOUS: %cmp11 = icmp sgt i32 %8, 3
TTTTT | 0x0 | 49 | 1 TTTTT
...
*PREVIOUS: store i32 %dec, i32* %i, align 4
TTTTT dec | 0x9b69130 | 30 | 1 TTTTT
...
*PREVIOUS: %cmp8 = icmp sle i32 %6, 2
TTTTT | 0x0 | 49 | 1 TTTTT
...
*PREVIOUS: store i32 %inc, i32* %i, align 4
TTTTT inc | 0x9b761c8 | 30 | 1 TTTTT
Do you know how I can get the operands from ICMP instructions? I need to use them in some conditions? (also their attributes).
Thank you a lot !
You ask:
Do you know how I can get the operands from ICMP instructions
But you did get the operands, you can use those values just fine. In your specific examples they don't have a name (numbered values such as %8 are considered nameless, and constants are obviously nameless), but they are still valid values.
Related
My table has some leading and trailing observations that I am trying to remove. I want to remove the rows that come before every 'begin' event and after every 'end' event for every single group. The table resembles the below:
| Time | Group | Event | Value |
| 1 | 1 | NA | 0 |
| 2 | 1 | NA | 0 |
| 3 | 1 | Begin | 1.1 |
| 4 | 1 | NA | 1.2 |
| 5 | 1 | NA | 1.3 |
| 6 | 1 | End | 1.4 |
| 7 | 1 | NA | 0 |
| 1 | 2 | NA | 0 |
| 2 | 2 | Begin | 1.1 |
| 3 | 2 | NA | 1.2 |
| 4 | 2 | End | 1.3 |
| 5 | 2 | NA | 1.4 |
On the presumption that the incoming data is already sorted and that there are zero or more serially bounded ranges of Begin to End within each group:
data want;
do until (last.group);
set have;
by group time;
if event = 'Begin' then _keeprow = 1;
if _keeprow then output;
if event = 'End' then _keeprow = 0;
end;
drop _keeprow;
end;
I have came out an easy way but will be limited by the actual data size.
data have;
input Time Group Event $ Value ;
datalines;
1 1 NA 0
2 1 NA 0
3 1 Begin 1.1
4 1 NA 1.2
5 1 NA 1.3
6 1 End 1.4
7 1 NA 0
1 2 NA 0
2 2 Begin 1.1
3 2 NA 1.2
4 2 End 1.3
5 2 NA 1.4
;
run;
proc sort data = have;
by group time;
run;
data have1;
set have;
count + 1;
by group;
if first.group then count = -100;
if event = 'Begin' then count = 0;
if event = 'End' then count = 100;
if count < 0 or count >100 then delete;
run;
The current code could be applied to the small size data if you have less than 100 observations between 'Begin' and 'End' and less than 100 observations before 'Begin'. You can adjust the initial count value according to the true data size.
one way to do is
data have;
input Time Group Event $ Value ;
datalines;
1 1 NA 0
2 1 NA 0
3 1 Begin 1.1
4 1 NA 1.2
5 1 NA 1.3
6 1 End 1.4
7 1 NA 0
1 2 NA 0
2 2 Begin 1.1
3 2 NA 1.2
4 2 End 1.3
5 2 NA 1.4
;
data have2(keep= Group min_var max_var);
set have;
by group;
retain min_var max_var;
if trim(Event)= "Begin" then min_var =_n_ ;
if trim(Event)= "End" then max_var =_n_;
if last.group;
run;
data want;
merge have have2;
by group;
if _n_ ge min_var and _n_ le max_var ;
drop min_var max_var;
run;
I am using a dataset with about 100 variables and 1000 rows, similar to the one below:
. var1 var2 var3 var4
AL 10 11 12 13
AK -1 0 0 18
AZ 5 -5 -2 22
VA 15 16 0 0
How can I list the variables / observations that have a negative value?
For example, I would like to list that AK has negative var1 and AZ has negative var2 and var3.
Here's an example of how you can create a marker variable for each of your var variables:
clear
input str2 state var1 var2 var3 var4
AL 10 11 12 13
AK -1 0 0 18
AZ 5 -5 -2 22
VA 15 16 0 0
end
foreach var in var1 var2 var3 var4 {
generate tag_`var' = `var' < 0
}
list
+-------------------------------------------------------------------------------+
| state var1 var2 var3 var4 tag_var1 tag_var2 tag_var3 tag_var4 |
|-------------------------------------------------------------------------------|
1. | AL 10 11 12 13 0 0 0 0 |
2. | AK -1 0 0 18 1 0 0 0 |
3. | AZ 5 -5 -2 22 0 1 1 0 |
4. | VA 15 16 0 0 0 0 0 0 |
+-------------------------------------------------------------------------------+
You can then do the following:
list state var1 if tag_var1 == 1
+--------------+
| state var1 |
|--------------|
2. | AK -1 |
+--------------+
or
list state var* if tag_var1 == 1 | tag_var2 == 1 | tag_var3 == 1 | tag_var4 == 1
+-----------------------------------+
| state var1 var2 var3 var4 |
|-----------------------------------|
2. | AK -1 0 0 18 |
3. | AZ 5 -5 -2 22 |
+-----------------------------------+
If you do not need the extra flexibility of a marker variable you can simply do:
list state var1 if var1 < 0
EDIT:
Alternatively you could do the following:
preserve
generate obsno = _n
reshape long var, i(obsno)
rename var value
generate var = "var" + string(_j)
list state var obsno value if value < 0, noobs sepby(state)
+------------------------------+
| state var obsno value |
|------------------------------|
| AK var1 2 -1 |
|------------------------------|
| AZ var2 3 -5 |
| AZ var3 3 -2 |
+------------------------------+
restore
There are two other techniques that can be mentioned. One is to calculate the minimum in each observation (row) and then list if and only if that minimum is negative. That way, you get any zeros, positives and missings too in the same observations.
The other is just to loop over the variables and list separately.
clear
input str2 state var1 var2 var3 var4
AL 10 11 12 13
AK -1 0 0 18
AZ 5 -5 -2 22
VA 15 16 0 0
end
egen min = rowmin(var*)
list if min < 0
+-----------------------------------------+
| state var1 var2 var3 var4 min |
|-----------------------------------------|
2. | AK -1 0 0 18 -1 |
3. | AZ 5 -5 -2 22 -5 |
+-----------------------------------------+
foreach v of var var* {
quietly count if `v' < 0
if r(N) list `v' if `v' < 0
}
+------+
| var1 |
|------|
2. | -1 |
+------+
+------+
| var2 |
|------|
3. | -5 |
+------+
+------+
| var3 |
|------|
3. | -2 |
+------+
When I execute following IR:
declare void #_puts(i32, ...)
define void #main() {
entry:
%name = alloca i32
br i1 true, label %then, label %else
then: ; preds = %entry
call void (i32, ...) #_puts(i32 1, i32 1234)
br label %end
else: ; preds = %entry
br label %end
end: ; preds = %else, %then
%if_val = phi i32 [ 1234, %then ], [ 0, %else ]
entry1: ; No predecessors!
store i32 %if_val, i32* %name
%name2 = load i32, i32* %name
call void (i32, ...) #_puts(i32 1, i32 %name2)
ret void
}
I got following error message:
Assertion failed: (!NodePtr->isKnownSentinel()), function operator*, file /Users/Mac/llvm-source/llvm/include/llvm/ADT/ilist_iterator.h, line 139.
Abort trap: 6
What does this message means?
Can anyone explain this for me?
Thanks a lot.
The message refers to a sentinel node of a simple_ilist, which is a data structure used for representing lists of functions in a module, basic blocks in a function, instructions in a basic blocks, and so on. A sentinel node represents the end of the list and is the only data member of such lists — the rest is inside the objects that constitute a list ("i" is for "intrusive").
I would guess that this message is caused by iterating over the end of a simple_ilist. Most likely the one holding the instructions in the end block, because this is the only block that is malformed. You can fix it by adding a terminator:
end: ; preds = %else, %then
%if_val = phi i32 [ 1234, %then ], [ 0, %else ]
br label %entry1
I'm new in SAS
and I have this example :
proc iml;
x={1 2 3 4 5 6 7 8 9};
y={2,3,5,4,8,6,4,2,2};
z={1,1,1,1,2,2,2,2,2};
data=t(x)||y||z;
print data;
run;
quit;
data
1 2 1
2 3 1
3 5 1
4 4 1
5 8 2
6 6 2
7 4 2
8 2 2
9 2 2
How can I creat new data with only Z=1 and only Z=2 ?
Thank you.
You could use the loc function to subset your data matrix. The following is the description of the function, snipped from Indexing matrices in Introduction to SAS/IML.
the LOC function is often very useful for subsetting vectors and matrices. This function is used for locating elements which meet a given condition. The positions of the elements are returned in row-major order. For vectors, this is simply the position of the element. For matrices, some manipulation is often required in order to use the result of the LOC function as an index. The syntax of the function is:
matrix2=LOC(matrix1=value);
Applied to your example:
proc iml;
x={1 2 3 4 5 6 7 8 9};
y={2,3,5,4,8,6,4,2,2};
z={1,1,1,1,2,2,2,2,2};
data=t(x)||y||z;
print data;
z1rows=loc(data[,3]= 1);
z1=data[z1rows,];
print z1;
z2rows=loc(data[,3]= 2);
z2=data[z2rows,];
print z2;
run;
quit;
The result for print z1;
+------------+
| z1 |
+---+----+---+
| 1 | 2 | 1 |
| 2 | 3 | 1 |
| 3 | 5 | 1 |
| 4 | 4 | 1 |
+---+----+---+
The result for print z2;
+------------+
| z2 |
+---+----+---+
| 5 | 8 | 2 |
| 6 | 6 | 2 |
| 7 | 4 | 2 |
| 8 | 2 | 2 |
| 9 | 2 | 2 |
+---+----+---+
I have a table MACRecord in MYSQL. I have 3 fields declared as TINYINT(4) (RSSI1, RSSI2, RSSI3) with a default value of 0. I use it to store signed negative values i-e -90, -84 etc. I am trying to understand how much length each number is taking in the column. I have a c++ code to output length of each column in bytes as follows:
lengths = mysql_fetch_lengths(result);
num_rows = mysql_num_rows(result);
for(i = 3; i < num_fields; i++)
{
if (strstr(fields[i].name, "RSSI") != NULL)
{
printf("Column %u is %lu bytes in length.\n",
i, lengths[i]);
}
So now for example if columns 3, 4 and 5 which are my RSSI's columns contain values such as -90, 0(default), -83, i get the output as follows:
Column 3 is 3 bytes in length
Column 4 is 1 bytes in length.
Column 5 is 3 bytes in length
I don't understand why having a value of for example -90 in my RSSI's columns which were declared as TINYINT(4) which can only store 1 byte values is displaying as having 3 bytes of data? The default value of 0 makes sense. If I describe my table I can see that the data type is TINYINT but still it says values 3 bytes in length.
| Field | Type | Null | Key | Default | Extra |
| RSSI1 | tinyint(4) | YES | | 0 | |
| RSSI2 | tinyint(4) | YES | | 0 | |
| RSSI3 | tinyint(4) | YES | | 0 | |
I am a bit confused. Any help will be appreciated.
don't understand why having a value of for example -90 in my RSSI's columns which were declared as TINYINT(4) which can only store 1 byte values
in binary ...
is displaying as having 3 bytes of data?
in decimal.
"-90" is three bytes in decimal, and -90 is one byte of binary.