[meta] Generate full documentation for instructions in InstBuilder;

This commit is contained in:
Benjamin Bouvier
2019-07-10 12:01:37 +02:00
parent 84a6795873
commit d5b80b2803
2 changed files with 2 additions and 12 deletions

View File

@@ -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) => {

View File

@@ -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| {