<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm new to LLVM and trying to understand instruction selection. I compiled this llvm IR using llc with the '-debug' flag
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: "Courier New", monospace;">define i32 @func() #0 {</span><span><br>
</span>
<div><span style="font-family: "Courier New", monospace;"> %a = alloca i32, align 4</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;"> %1 = load i32, i32* %a, align 4</span></div>
<div><span style="font-family: "Courier New", monospace;"> ret i32 %1</span><br>
</div>
<span style="font-family: "Courier New", monospace;">}</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>The resulting assembly is</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span></span><span></span><span style="font-family: "Courier New", monospace;">ADS -8</span><span><br>
</span>
<div><span style="font-family: "Courier New", monospace;">LDW $r0, $sp, 0 # 4-byte Folded Reload</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">MOVR $r0, $r0</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">LDW $r4, $r0, 0</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">STSP $r0, 0</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">ADS 8</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">JLR</span><br>
</div>
<span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm trying to understand why r0 is being moved to itself. The debug output indicates this:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: "Courier New", monospace;">ISEL: Starting selection on root node: t1: i32 = FrameIndex<0></span><span><br>
</span>
<div><span style="font-family: "Courier New", monospace;">ISEL: Starting pattern match</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;"> Morphed node: t1: i32 = MOVR t1</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">ISEL: Match complete!</span><br>
</div>
<span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
In InstrInfo.td, MOVR has this dag pattern: <span style="font-family: "Courier New", monospace;">
[(set CPURegs:$ra, CPURegs:$rb)]</span>. I don't understand how node t1's pattern matched MOVR's pattern.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Can someone point me to a location in the code where FrameIndex's pattern is defined?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks.<br>
</div>
</body>
</html>