@@ -58,47 +58,29 @@ u32 larch_insn_gen_nop(void)
58
58
u32 larch_insn_gen_b (unsigned long pc , unsigned long dest )
59
59
{
60
60
long offset = dest - pc ;
61
- unsigned int immediate_l , immediate_h ;
62
61
union loongarch_instruction insn ;
63
62
64
63
if ((offset & 3 ) || offset < - SZ_128M || offset >= SZ_128M ) {
65
64
pr_warn ("The generated b instruction is out of range.\n" );
66
65
return INSN_BREAK ;
67
66
}
68
67
69
- offset >>= 2 ;
70
-
71
- immediate_l = offset & 0xffff ;
72
- offset >>= 16 ;
73
- immediate_h = offset & 0x3ff ;
74
-
75
- insn .reg0i26_format .opcode = b_op ;
76
- insn .reg0i26_format .immediate_l = immediate_l ;
77
- insn .reg0i26_format .immediate_h = immediate_h ;
68
+ emit_b (& insn , offset >> 2 );
78
69
79
70
return insn .word ;
80
71
}
81
72
82
73
u32 larch_insn_gen_bl (unsigned long pc , unsigned long dest )
83
74
{
84
75
long offset = dest - pc ;
85
- unsigned int immediate_l , immediate_h ;
86
76
union loongarch_instruction insn ;
87
77
88
78
if ((offset & 3 ) || offset < - SZ_128M || offset >= SZ_128M ) {
89
79
pr_warn ("The generated bl instruction is out of range.\n" );
90
80
return INSN_BREAK ;
91
81
}
92
82
93
- offset >>= 2 ;
94
-
95
- immediate_l = offset & 0xffff ;
96
- offset >>= 16 ;
97
- immediate_h = offset & 0x3ff ;
98
-
99
- insn .reg0i26_format .opcode = bl_op ;
100
- insn .reg0i26_format .immediate_l = immediate_l ;
101
- insn .reg0i26_format .immediate_h = immediate_h ;
83
+ emit_bl (& insn , offset >> 2 );
102
84
103
85
return insn .word ;
104
86
}
@@ -107,10 +89,7 @@ u32 larch_insn_gen_or(enum loongarch_gpr rd, enum loongarch_gpr rj, enum loongar
107
89
{
108
90
union loongarch_instruction insn ;
109
91
110
- insn .reg3_format .opcode = or_op ;
111
- insn .reg3_format .rd = rd ;
112
- insn .reg3_format .rj = rj ;
113
- insn .reg3_format .rk = rk ;
92
+ emit_or (& insn , rd , rj , rk );
114
93
115
94
return insn .word ;
116
95
}
@@ -124,9 +103,7 @@ u32 larch_insn_gen_lu12iw(enum loongarch_gpr rd, int imm)
124
103
{
125
104
union loongarch_instruction insn ;
126
105
127
- insn .reg1i20_format .opcode = lu12iw_op ;
128
- insn .reg1i20_format .rd = rd ;
129
- insn .reg1i20_format .immediate = imm ;
106
+ emit_lu12iw (& insn , rd , imm );
130
107
131
108
return insn .word ;
132
109
}
@@ -135,9 +112,7 @@ u32 larch_insn_gen_lu32id(enum loongarch_gpr rd, int imm)
135
112
{
136
113
union loongarch_instruction insn ;
137
114
138
- insn .reg1i20_format .opcode = lu32id_op ;
139
- insn .reg1i20_format .rd = rd ;
140
- insn .reg1i20_format .immediate = imm ;
115
+ emit_lu32id (& insn , rd , imm );
141
116
142
117
return insn .word ;
143
118
}
@@ -146,10 +121,7 @@ u32 larch_insn_gen_lu52id(enum loongarch_gpr rd, enum loongarch_gpr rj, int imm)
146
121
{
147
122
union loongarch_instruction insn ;
148
123
149
- insn .reg2i12_format .opcode = lu52id_op ;
150
- insn .reg2i12_format .rd = rd ;
151
- insn .reg2i12_format .rj = rj ;
152
- insn .reg2i12_format .immediate = imm ;
124
+ emit_lu52id (& insn , rd , rj , imm );
153
125
154
126
return insn .word ;
155
127
}
@@ -158,10 +130,7 @@ u32 larch_insn_gen_jirl(enum loongarch_gpr rd, enum loongarch_gpr rj, unsigned l
158
130
{
159
131
union loongarch_instruction insn ;
160
132
161
- insn .reg2i16_format .opcode = jirl_op ;
162
- insn .reg2i16_format .rd = rd ;
163
- insn .reg2i16_format .rj = rj ;
164
- insn .reg2i16_format .immediate = (dest - pc ) >> 2 ;
133
+ emit_jirl (& insn , rj , rd , (dest - pc ) >> 2 );
165
134
166
135
return insn .word ;
167
136
}
0 commit comments