[meta] Generate full documentation for instructions in InstBuilder;
This commit is contained in:
@@ -97,7 +97,7 @@ pub struct InstructionContent {
|
|||||||
pub opcode_number: OpcodeNumber,
|
pub opcode_number: OpcodeNumber,
|
||||||
|
|
||||||
/// Documentation string.
|
/// Documentation string.
|
||||||
doc: String,
|
pub doc: String,
|
||||||
|
|
||||||
/// Input operands. This can be a mix of SSA value operands and other operand kinds.
|
/// Input operands. This can be a mix of SSA value operands and other operand kinds.
|
||||||
pub operands_in: Vec<Operand>,
|
pub operands_in: Vec<Operand>,
|
||||||
@@ -162,16 +162,6 @@ impl Instruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn doc_comment_first_line(&self) -> &str {
|
|
||||||
for line in self.doc.split("\n") {
|
|
||||||
let stripped = line.trim();
|
|
||||||
if stripped.len() > 0 {
|
|
||||||
return stripped;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
""
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn all_typevars(&self) -> Vec<&TypeVar> {
|
pub fn all_typevars(&self) -> Vec<&TypeVar> {
|
||||||
match &self.polymorphic_info {
|
match &self.polymorphic_info {
|
||||||
Some(poly) => {
|
Some(poly) => {
|
||||||
|
|||||||
@@ -930,7 +930,7 @@ fn gen_inst_builder(inst: &Instruction, format: &InstructionFormat, fmt: &mut Fo
|
|||||||
rtype
|
rtype
|
||||||
);
|
);
|
||||||
|
|
||||||
fmt.doc_comment(format!("`{}`\n\n{}", inst, inst.doc_comment_first_line()));
|
fmt.doc_comment(&inst.doc);
|
||||||
fmt.line("#[allow(non_snake_case)]");
|
fmt.line("#[allow(non_snake_case)]");
|
||||||
fmtln!(fmt, "fn {} {{", proto);
|
fmtln!(fmt, "fn {} {{", proto);
|
||||||
fmt.indent(|fmt| {
|
fmt.indent(|fmt| {
|
||||||
|
|||||||
Reference in New Issue
Block a user